@@ -21,6 +21,7 @@ import (
2121 "os"
2222
2323 "github.com/go-logr/zapr"
24+ "go.uber.org/zap/zapcore"
2425
2526 "github.com/aws/aws-application-networking-k8s/pkg/aws"
2627 "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog"
@@ -91,17 +92,16 @@ func main() {
9192 var metricsAddr string
9293 var enableLeaderElection bool
9394 var probeAddr string
94- var debug bool
9595
9696 flag .StringVar (& metricsAddr , "metrics-bind-address" , ":8080" , "The address the metric endpoint binds to." )
9797 flag .StringVar (& probeAddr , "health-probe-bind-address" , ":8081" , "The address the probe endpoint binds to." )
98- flag .BoolVar (& debug , "debug" , false , "enable debug mode" )
9998 flag .BoolVar (& enableLeaderElection , "leader-elect" , false ,
10099 "Enable leader election for controller manager. " +
101100 "Enabling this will ensure there is only one active controller manager." )
102101 flag .Parse ()
103102
104- log := gwlog .NewLogger (debug )
103+ logLevel := logLevel ()
104+ log := gwlog .NewLogger (logLevel )
105105 ctrl .SetLogger (zapr .NewLogger (log .Desugar ()).WithName ("runtime" ))
106106
107107 setupLog := log .Named ("setup" )
@@ -220,3 +220,17 @@ func main() {
220220 }
221221
222222}
223+
224+ func logLevel () zapcore.Level {
225+ level := os .Getenv ("LOG_LEVEL" )
226+ switch level {
227+ case "debug" :
228+ return zapcore .DebugLevel
229+ case "error" :
230+ return zapcore .ErrorLevel
231+ case "panic" :
232+ return zapcore .PanicLevel
233+ default :
234+ return zapcore .InfoLevel
235+ }
236+ }
0 commit comments