Skip to content

Commit

Permalink
Use 'switch' instead of 'if' to check the logFormat. Return error if …
Browse files Browse the repository at this point in the history
…the value is not valid
  • Loading branch information
Mohammed Ammer committed Nov 5, 2024
1 parent d3562a1 commit 2e1fc41
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/slo_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ func setupLogger(logLevel string, logFormat string) (*logrus.Logger, error) {
return nil, err
}

if logFormat != "json" && logFormat != "text" {
logFormat = "text"
logrus.Warningf("invalid log format '%s', using 'text' instead", logFormat)
switch logFormat {
case "json", "text":
default:
return nil, fmt.Errorf("invalid log format '%s', must be 'json' or 'text'", logFormat)
}

newLogger := logrus.New()
Expand Down

0 comments on commit 2e1fc41

Please sign in to comment.