Skip to content

Commit

Permalink
improve log colors
Browse files Browse the repository at this point in the history
  • Loading branch information
breadchris committed Dec 17, 2021
1 parent 2dd8391 commit 7ebe74f
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions tools/log4shell/commands/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,29 @@ func enableGlobalFlags(c *cli.Context) {
return fmt.Sprintf("\n\t%s: ", util.Colorize(constants.ColorBlue, i))
}


consoleOutput.FormatLevel = func(i interface{}) string {
if (i == nil){
if i == nil {
return util.Colorize(constants.ColorBold,"Scan Result:")
}
return fmt.Sprintf("| %-6s |", i)

level := i.(string)

var formattedLevel string
switch level {
case "warn":
formattedLevel = util.Colorize(constants.ColorYellow, level)
case "error":
formattedLevel = util.Colorize(constants.ColorRed, level)
case "info":
formattedLevel = util.Colorize(constants.ColorBlue, level)
case "debug":
formattedLevel = util.Colorize(constants.ColorGreen, level)
default:
formattedLevel = util.Colorize(constants.ColorWhite, level)
}
return fmt.Sprintf("| %s |", formattedLevel)
}

log.Logger = log.Output(consoleOutput)

}
Expand Down

0 comments on commit 7ebe74f

Please sign in to comment.