diff --git a/log/command.go b/log/command.go index 7ea959e02..aff18cfbe 100644 --- a/log/command.go +++ b/log/command.go @@ -28,6 +28,13 @@ func (o Options) Run() error { l.SetPrefix(o.Prefix) l.SetLevel(-math.MaxInt32) // log all levels l.SetReportTimestamp(o.Time != "") + if o.MinLevel != "" { + lvl, err := log.ParseLevel(o.MinLevel) + if err != nil { + return err + } + l.SetLevel(lvl) + } timeFormats := map[string]string{ "layout": time.Layout, diff --git a/log/options.go b/log/options.go index 9a19f3654..73fbcece6 100644 --- a/log/options.go +++ b/log/options.go @@ -16,6 +16,8 @@ type Options struct { Structured bool `short:"s" help:"Use structured logging" xor:"format,structured"` Time string `short:"t" help:"The time format to use (kitchen, layout, ansic, rfc822, etc...)" default:""` + MinLevel string `help:"Minimal level to show" default:"" env:"GUM_LOG_LEVEL"` + LevelStyle style.Styles `embed:"" prefix:"level." help:"The style of the level being used" set:"defaultBold=true" envprefix:"GUM_LOG_LEVEL_"` //nolint:staticcheck TimeStyle style.Styles `embed:"" prefix:"time." help:"The style of the time" envprefix:"GUM_LOG_TIME_"` PrefixStyle style.Styles `embed:"" prefix:"prefix." help:"The style of the prefix" set:"defaultBold=true" set:"defaultFaint=true" envprefix:"GUM_LOG_PREFIX_"` //nolint:staticcheck