From e36070f0b6c5e3a9faae0291eb534e786b772237 Mon Sep 17 00:00:00 2001 From: Maas Lalani Date: Wed, 8 Nov 2023 11:33:56 -0500 Subject: [PATCH] feat(log): time format flag -> time flag --- log/command.go | 6 +++--- log/options.go | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/log/command.go b/log/command.go index 674b3f4dd5..8c4b09a2ad 100644 --- a/log/command.go +++ b/log/command.go @@ -27,7 +27,7 @@ func (o Options) Run() error { l.SetPrefix(o.Prefix) l.SetLevel(-math.MaxInt32) // log all levels - l.SetReportTimestamp(o.Time) + l.SetReportTimestamp(o.Time != "") timeFormats := map[string]string{ "layout": time.Layout, @@ -51,11 +51,11 @@ func (o Options) Run() error { "timeonly": time.TimeOnly, } - tf, ok := timeFormats[strings.ToLower(o.TimeFormat)] + tf, ok := timeFormats[strings.ToLower(o.Time)] if ok { l.SetTimeFormat(tf) } else { - l.SetTimeFormat(o.TimeFormat) + l.SetTimeFormat(o.Time) } st := log.DefaultStyles() diff --git a/log/options.go b/log/options.go index 92b45ba264..d3ee8c52be 100644 --- a/log/options.go +++ b/log/options.go @@ -15,8 +15,7 @@ type Options struct { Level string `short:"l" help:"The log level to use" enum:"none,debug,info,warn,error,fatal" default:"none"` Prefix string `help:"Prefix to print before the message"` Structured bool `short:"s" help:"Use structured logging" xor:"format,structured"` - Time bool `short:"t" help:"Whether to print the time"` - TimeFormat string `help:"The time format to use" default:"15:04:05"` + Time string `short:"t" help:"The time format to use" default:""` 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_"`