@@ -12,6 +12,7 @@ import (
1212 "os"
1313 "path/filepath"
1414 "slices"
15+ "strings"
1516 "time"
1617
1718 // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
@@ -151,10 +152,27 @@ func main() {
151152
152153 ctrl .SetLogger (zap .New (zap .UseFlagOptions (& opts )))
153154
154- // Configure slog (used across internal packages) with structured JSON output.
155+ // Configure slog (used across internal packages) with JSON output and
156+ // level control via the LOG_LEVEL environment variable.
157+ // Supported values: debug, info (default), warn, error.
158+ slogLevel := new (slog.LevelVar )
159+ slogLevel .Set (slog .LevelInfo )
160+ if lvl := os .Getenv ("LOG_LEVEL" ); lvl != "" {
161+ switch strings .ToLower (lvl ) {
162+ case "debug" :
163+ slogLevel .Set (slog .LevelDebug )
164+ case "info" :
165+ slogLevel .Set (slog .LevelInfo )
166+ case "warn" , "warning" :
167+ slogLevel .Set (slog .LevelWarn )
168+ case "error" :
169+ slogLevel .Set (slog .LevelError )
170+ }
171+ }
155172 slog .SetDefault (slog .New (slog .NewJSONHandler (os .Stdout , & slog.HandlerOptions {
156- Level : slog . LevelInfo ,
173+ Level : slogLevel ,
157174 })))
175+ slog .Info ("slog configured" , "level" , slogLevel .Level ().String ())
158176
159177 // Log the main configuration
160178 setupLog .Info ("loaded main configuration" ,
0 commit comments