Skip to content

Commit

Permalink
adding a call to controller-runtimes SetLogger and io.Discard to avoi…
Browse files Browse the repository at this point in the history
…d controller-runtimes noise in logging

Signed-off-by: Adam D. Cornett <adc@redhat.com>
  • Loading branch information
acornett21 authored and bcrochet committed May 8, 2024
1 parent 27ba8c9 commit 5fa97bf
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/preflight/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
spfviper "github.com/spf13/viper"
ctrl "sigs.k8s.io/controller-runtime"
)

var configFileUsed bool
Expand Down Expand Up @@ -133,5 +134,12 @@ func preRunConfig(cmd *cobra.Command, args []string) {

logger := logrusr.New(l)
ctx := logr.NewContext(cmd.Context(), logger)

// Setting the controller-runtime logger to a no-op logger by default,
// unless debug mode is enabled. This is because the controller-runtime
// logger is *very* verbose even at info level. This is not really needed,
// but otherwise we get a warning from the controller-runtime.
ctrl.SetLogger(logr.Discard())

cmd.SetContext(ctx)
}

0 comments on commit 5fa97bf

Please sign in to comment.