Skip to content

Commit

Permalink
chore: Add environment variable to change operator logging level (#651)
Browse files Browse the repository at this point in the history
Signed-off-by: Anand Kumar Singh <[email protected]>
  • Loading branch information
anandrkskd authored Feb 19, 2024
1 parent f0d8b69 commit b125af9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,27 @@ func main() {
"Enabling this will ensure there is only one active controller manager.")
flag.BoolVar(&enableHTTP2, "enable-http2", enableHTTP2, "If HTTP/2 should be enabled for the metrics and webhook servers.")

//Configure log level
logLevelStr := strings.ToLower(os.Getenv("LOG_LEVEL"))
logLevel := zapcore.InfoLevel
switch logLevelStr {
case "debug":
logLevel = zapcore.DebugLevel
case "info":
logLevel = zapcore.InfoLevel
case "warn":
logLevel = zapcore.WarnLevel
case "error":
logLevel = zapcore.ErrorLevel
case "panic":
logLevel = zapcore.PanicLevel
case "fatal":
logLevel = zapcore.FatalLevel
}

opts := zap.Options{
Development: true,
Level: logLevel,
TimeEncoder: zapcore.RFC3339TimeEncoder,
}
opts.BindFlags(flag.CommandLine)
Expand Down

0 comments on commit b125af9

Please sign in to comment.