Skip to content

Commit 2e1fc41

Browse files
author
Mohammed Ammer
committed
Use 'switch' instead of 'if' to check the logFormat. Return error if the value is not valid
1 parent d3562a1 commit 2e1fc41

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cmd/slo_exporter.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,10 @@ func setupLogger(logLevel string, logFormat string) (*logrus.Logger, error) {
100100
return nil, err
101101
}
102102

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

108109
newLogger := logrus.New()

0 commit comments

Comments
 (0)