Skip to content

Color Customization

Michael Kenney edited this page Mar 9, 2019 · 10 revisions

Release v0.1.16 adds all the color fields to the JSON formatter and allows custom colors to be defined using ANSI color escape sequences. Color variables are exported at the package level and can be found in formatter.go.

To define your own colors, simply set them in your script:

// DEFAULTColor is the default TTY 'level' color. This color is used for INFO
// level log messages
log.DEFAULTColor = "\033[38;5;46m"
// ERRORColor is the TTY 'level' color for error messages.
log.ERRORColor = "\033[38;5;208m"
// FATALColor is the TTY 'level' color for fatal messages.
log.FATALColor = "\033[38;5;124m"
// PANICColor is the TTY 'level' color for panic messages.
log.PANICColor = "\033[38;5;196m"
// WARNColor is the TTY 'level' color for warning messages.
log.WARNColor = "\033[38;5;226m"
// DEBUGColor is the TTY 'level' color for debug messages.
log.DEBUGColor = "\033[38;5;245m"

// CallerColor is the TTY caller color.
log.CallerColor = "\033[38;5;244m"
// DataLabelColor is the TTY data label color.
log.DataLabelColor = "\033[38;5;111m"
// DataValueColor is the TTY data value color.
log.DataValueColor = "\033[38;5;180m"
// HostnameColor is the TTY hostname color.
log.HostnameColor = "\033[38;5;39m"
// TraceColor is the TTY trace color.
log.TraceColor = "\033[38;5;244m"
// TimestampColor is the TTY timestamp color.
log.TimestampColor = "\033[38;5;72m"

// ResetColor resets the TTY color scheme to it's default value.
log.ResetColor = "\033[0m"