Format implements logrus.Formatter
(entry *logrus.Entry)
| 113 | |
| 114 | // Format implements logrus.Formatter |
| 115 | func (f logFormat) Format(entry *logrus.Entry) ([]byte, error) { |
| 116 | buf := new(bytes.Buffer) |
| 117 | |
| 118 | buf.WriteByte('[') |
| 119 | if f.hasColor { |
| 120 | buf.WriteString(getLogLevelColorCode(entry.Level)) |
| 121 | } |
| 122 | buf.WriteString(strings.ToUpper(entry.Level.String())) |
| 123 | if f.hasColor { |
| 124 | buf.WriteString(colorReset) |
| 125 | } |
| 126 | buf.WriteString("] ") |
| 127 | buf.WriteString(entry.Message) |
| 128 | buf.WriteString(" \n") |
| 129 | |
| 130 | return buf.Bytes(), nil |
| 131 | } |
| 132 | |
| 133 | // getLogLevelColorCode 获取日志等级对应色彩code |
| 134 | func getLogLevelColorCode(level logrus.Level) string { |
no test coverage detected