Skip to content
Myr

feat(log): support setting minimum log level with GUM_LOG_LEVEL (#723)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

closes #490

authored by Carlos Alexandro Becker · committed by GitHub · parent c868aa1 · Browse files · 2 files+9 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+9 added−0 removed

  • other:+9 added−0 removed

2 files+9 added−0 removed

modified:log/command.go+7 added
26 unmodified lines
2728 l.SetPrefix(o.Prefix)29 l.SetLevel(-math.MaxInt32) // log all levels30 l.SetReportTimestamp(o.Time != "")31 if o.MinLevel != "" {32 lvl, err := log.ParseLevel(o.MinLevel)33 if err != nil {34 return err35 }36 l.SetLevel(lvl)37 }3839 timeFormats := map[string]string{40 "layout": time.Layout,41 "ansic": time.ANSIC,
107 unmodified lines
modified:log/options.go+2 added
14 unmodified lines
15 Prefix string `help:"Prefix to print before the message"`16 Structured bool `short:"s" help:"Use structured logging" xor:"format,structured"`17 Time string `short:"t" help:"The time format to use (kitchen, layout, ansic, rfc822, etc...)" default:""`1819 MinLevel string `help:"Minimal level to show" default:"" env:"GUM_LOG_LEVEL"`2021 LevelStyle style.Styles `embed:"" prefix:"level." help:"The style of the level being used" set:"defaultBold=true" envprefix:"GUM_LOG_LEVEL_"` //nolint:staticcheck22 TimeStyle style.Styles `embed:"" prefix:"time." help:"The style of the time" envprefix:"GUM_LOG_TIME_"`23 PrefixStyle style.Styles `embed:"" prefix:"prefix." help:"The style of the prefix" set:"defaultBold=true" set:"defaultFaint=true" envprefix:"GUM_LOG_PREFIX_"` //nolint:staticcheck24 MessageStyle style.Styles `embed:"" prefix:"message." help:"The style of the message" envprefix:"GUM_LOG_MESSAGE_"`
4 unmodified lines