Skip to content

Commit

Permalink
Added back support for warn color to console logger
Browse files Browse the repository at this point in the history
Makes it more convenient to re-use in other loggers, or with raw zap.
  • Loading branch information
ansel1 committed Sep 20, 2019
1 parent 372d47b commit 30c5a98
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion console_encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Colorizer interface {
// Colors is an implementation of the Colorizer interface, which assigns colors
// to the default log levels.
type Colors struct {
Debug, Info, Error string
Debug, Info, Warn, Error string
}

// Level implements Colorizer
Expand All @@ -39,6 +39,8 @@ func (c *Colors) Level(l Level) string {
return c.Debug
case InfoLevel:
return c.Info
case Level(zapcore.WarnLevel):
return c.Warn
default:
return c.Error
}
Expand All @@ -49,6 +51,7 @@ func (c *Colors) Level(l Level) string {
var DefaultColors = Colors{
Debug: ansi.ColorCode("cyan"),
Info: ansi.ColorCode("green+h"),
Warn: ansi.ColorCode("yellow+bh"),
Error: ansi.ColorCode("red+bh"),
}

Expand Down

0 comments on commit 30c5a98

Please sign in to comment.