Documentation ¶
Index ¶
Constants ¶
View Source
const ( HumanizeFormatVar = "HUMANIZE" FormatFull = "FULL" FormatCompact = "COMPACT" FormatJSON = "JSON" )
Log-level configuration from env vars
Variables ¶
View Source
var DefaultLevelColors = map[logrus.Level]int{ logrus.DebugLevel: blue, logrus.ErrorLevel: red, logrus.FatalLevel: red, logrus.WarnLevel: yellow, logrus.TraceLevel: grey, logrus.PanicLevel: red, }
View Source
var ElementColors = map[string]int{
"date": grey,
"time": blue,
"caller": green,
}
Functions ¶
func NewHumanizeFormatterFromEnv ¶
NewHumanizeFormatterFromEnv reads a configuration variable from the environment, using it to configure and return a logger. Humanize looks for its configuration using the value of the `HumanizeFormatVar` constant, and can respond to one of three values:
- FULL -> Format using long formatting (this is the default).
- COMPACT -> Format using compact formatting.
- JSON -> Return the default Fallback formatter, logrus.JSONFormatter
Types ¶
type Formatter ¶
type Formatter struct { // It's possible you don't want ISO-8601. You're wrong, but... OK. DateTimeFormat string // Take up more whitespace or less. Compact bool // We assume you wont want to ship logs to logstash or what have you in this // format. What do we use when a human isn't looking? Fallback logrus.Formatter // contains filtered or unexported fields }
Formatter renders Logrus log lines in a nicer format for humans.
func NewHumanizeFormatter ¶
func NewHumanizeFormatter() *Formatter
NewHumanizeFormatter creates a new formatter with defaults set.
Click to show internal directories.
Click to hide internal directories.