Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ajsutton authored and bnoieh committed Apr 28, 2024
1 parent bc4359f commit dfa91fa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions op-service/log/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,20 @@ func FormatHandler(ft FormatType, color bool) func(io.Writer) slog.Handler {
termColorHandler := func(w io.Writer) slog.Handler {
return log.NewTerminalHandler(w, color)
}
logfmtHandler := func(w io.Writer) slog.Handler { return log.LogfmtHandlerWithLevel(w, log.LevelTrace) }
switch ft {
case FormatJSON:
return log.JSONHandler
case FormatText:
if term.IsTerminal(int(os.Stdout.Fd())) {
return termColorHandler
} else {
return log.LogfmtHandler
return logfmtHandler
}
case FormatTerminal:
return termColorHandler
case FormatLogFmt:
return log.LogfmtHandler
return logfmtHandler
default:
panic(fmt.Errorf("failed to create slog.Handler factory for format-type=%q and color=%v", ft, color))
}
Expand Down

0 comments on commit dfa91fa

Please sign in to comment.