Format implements logrus.Formatter
(entry *logrus.Entry)
| 103 | |
| 104 | // Format implements logrus.Formatter |
| 105 | func (f logFormat) Format(entry *logrus.Entry) ([]byte, error) { |
| 106 | buf := new(bytes.Buffer) |
| 107 | |
| 108 | buf.WriteByte('[') |
| 109 | if f.hasColor { |
| 110 | buf.WriteString(getLogLevelColorCode(entry.Level)) |
| 111 | } |
| 112 | buf.WriteString(strings.ToUpper(entry.Level.String())) |
| 113 | if f.hasColor { |
| 114 | buf.WriteString(colorReset) |
| 115 | } |
| 116 | buf.WriteString("] ") |
| 117 | buf.WriteString(entry.Message) |
| 118 | buf.WriteString(" \n") |
| 119 | |
| 120 | return buf.Bytes(), nil |
| 121 | } |
| 122 | |
| 123 | // getLogLevelColorCode 获取日志等级对应色彩code |
| 124 | func getLogLevelColorCode(level logrus.Level) string { |
no test coverage detected