Skip to content

Commit

Permalink
Verbosity numbers now correspond to slog log Levels
Browse files Browse the repository at this point in the history
  • Loading branch information
miampf committed Jan 29, 2024
1 parent 0cd298c commit f1ae7c4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/logger/cmdline.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ import (
)

// CmdLineVerbosityDescription explains numeric log levels.
const CmdLineVerbosityDescription = "log verbosity in slog logging levels. Use -1 for debug information, 0 for info, 1 for warn, 2 for error"
const CmdLineVerbosityDescription = "log verbosity in slog logging levels. Use -4 for debug information, 0 for info, 4 for warn, 8 for error"

// VerbosityFromInt converts a verbosity level from an integer to a slog.Level.
func VerbosityFromInt(verbosity int) slog.Level {
switch {
case verbosity <= -1:
case verbosity <= -4:
return slog.LevelDebug
case verbosity == 0:
return slog.LevelInfo
case verbosity == 1:
case verbosity == 4:
return slog.LevelWarn
case verbosity >= 2:
case verbosity >= 8:
return slog.LevelError
default:
return slog.LevelInfo
Expand Down

0 comments on commit f1ae7c4

Please sign in to comment.