Skip to content

Commit

Permalink
feat(log): time format flag -> time flag
Browse files Browse the repository at this point in the history
  • Loading branch information
maaslalani committed Nov 8, 2023
1 parent b8f659a commit e36070f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions log/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -51,11 +51,11 @@ func (o Options) Run() error {
"timeonly": time.TimeOnly,

Check failure on line 51 in log/command.go

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

undefined: time.TimeOnly

Check failure on line 51 in log/command.go

View workflow job for this annotation

GitHub Actions / build (macos-latest)

undefined: time.TimeOnly

Check failure on line 51 in log/command.go

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

undefined: time.TimeOnly

Check failure on line 51 in log/command.go

View workflow job for this annotation

GitHub Actions / build (macos-latest)

undefined: 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()
Expand Down
3 changes: 1 addition & 2 deletions log/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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_"`
Expand Down

0 comments on commit e36070f

Please sign in to comment.