Skip to content

Commit 65204cc

Browse files
hogklintTakashi Kusumi
andauthored
Add log level color keys and handle default (#264)
* Add log level color keys Also adding a default white color when the key is not recognize. Without the default an error is printed instead of the log entry. * Fallback to default terminal color on unknown log level Co-authored-by: Takashi Kusumi <tkusumi@zlab.co.jp> --------- Co-authored-by: Takashi Kusumi <tkusumi@zlab.co.jp>
1 parent d7d5a4f commit 65204cc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

cmd/cmd.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,8 @@ func (o *options) generateTemplate() (*template.Template, error) {
486486
levelColor = color.New(color.FgBlue)
487487
case "warn":
488488
levelColor = color.New(color.FgYellow)
489+
case "warning":
490+
levelColor = color.New(color.FgYellow)
489491
case "error":
490492
levelColor = color.New(color.FgRed)
491493
case "dpanic":
@@ -494,7 +496,10 @@ func (o *options) generateTemplate() (*template.Template, error) {
494496
levelColor = color.New(color.FgRed)
495497
case "fatal":
496498
levelColor = color.New(color.FgCyan)
499+
case "critical":
500+
levelColor = color.New(color.FgCyan)
497501
default:
502+
return level
498503
}
499504
return levelColor.SprintFunc()(level)
500505
},

0 commit comments

Comments
 (0)