Skip to content

Commit 88f32be

Browse files
ngopalak-redhatk8s-ci-robot
authored andcommitted
Fix the logging at the given verbosity
1 parent e764698 commit 88f32be

File tree

1 file changed

+8
-1
lines changed
  • cmd/security-profiles-operator

1 file changed

+8
-1
lines changed

cmd/security-profiles-operator/main.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
_ "net/http/pprof" //nolint:gosec // required for profiling
2727
"os"
2828
"os/exec"
29+
"strconv"
2930
"strings"
3031
"time"
3132

@@ -283,7 +284,8 @@ func initialize(ctx *cli.Context) error {
283284
}
284285

285286
func initLogging(ctx *cli.Context) error {
286-
ctrl.SetLogger(textlogger.NewLogger(textlogger.NewConfig()))
287+
logConfig := textlogger.NewConfig()
288+
ctrl.SetLogger(textlogger.NewLogger(logConfig))
287289

288290
set := flag.NewFlagSet("logging", flag.ContinueOnError)
289291
klog.InitFlags(set)
@@ -294,6 +296,11 @@ func initLogging(ctx *cli.Context) error {
294296
}
295297

296298
ctrl.SetLogger(ctrl.Log.V(int(level)))
299+
300+
if err := logConfig.Verbosity().Set(strconv.FormatUint(uint64(level), 10)); err != nil {
301+
return fmt.Errorf("setting the verbosity flag to level %d : %w", level, err)
302+
}
303+
297304
ctrl.Log.Info(fmt.Sprintf("Set logging verbosity to %d", level))
298305

299306
return nil

0 commit comments

Comments
 (0)