Skip to content

Commit b125af9

Browse files
authored
chore: Add environment variable to change operator logging level (#651)
Signed-off-by: Anand Kumar Singh <[email protected]>
1 parent f0d8b69 commit b125af9

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

main.go

+19
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,27 @@ func main() {
9494
"Enabling this will ensure there is only one active controller manager.")
9595
flag.BoolVar(&enableHTTP2, "enable-http2", enableHTTP2, "If HTTP/2 should be enabled for the metrics and webhook servers.")
9696

97+
//Configure log level
98+
logLevelStr := strings.ToLower(os.Getenv("LOG_LEVEL"))
99+
logLevel := zapcore.InfoLevel
100+
switch logLevelStr {
101+
case "debug":
102+
logLevel = zapcore.DebugLevel
103+
case "info":
104+
logLevel = zapcore.InfoLevel
105+
case "warn":
106+
logLevel = zapcore.WarnLevel
107+
case "error":
108+
logLevel = zapcore.ErrorLevel
109+
case "panic":
110+
logLevel = zapcore.PanicLevel
111+
case "fatal":
112+
logLevel = zapcore.FatalLevel
113+
}
114+
97115
opts := zap.Options{
98116
Development: true,
117+
Level: logLevel,
99118
TimeEncoder: zapcore.RFC3339TimeEncoder,
100119
}
101120
opts.BindFlags(flag.CommandLine)

0 commit comments

Comments
 (0)