Skip to content

Commit

Permalink
cli: send controller-runtime logs to /dev/null (#6275)
Browse files Browse the repository at this point in the history
this has been noticed in a few places, including
#6265

all users of controller-runtime now need to set a default logger

Signed-off-by: Nick Santos <nick.santos@docker.com>
  • Loading branch information
nicks committed Dec 4, 2023
1 parent 43f9c6a commit c3e3ecc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/cli/cli.go
Expand Up @@ -8,9 +8,11 @@ import (
"syscall"
"time"

"github.com/go-logr/logr"
"github.com/spf13/cobra"
"go.lsp.dev/protocol"
"k8s.io/cli-runtime/pkg/genericclioptions"
ctrllog "sigs.k8s.io/controller-runtime/pkg/log"

"github.com/tilt-dev/starlark-lsp/pkg/cli"
tiltanalytics "github.com/tilt-dev/tilt/internal/analytics"
Expand Down Expand Up @@ -111,6 +113,7 @@ func createContext() (ctx context.Context, cleanup func()) {
}

func preCommand(ctx context.Context, cmdName model.TiltSubcommand) context.Context {

l := logger.NewLogger(logLevel(verbose, debug), os.Stdout)
ctx = logger.WithLogger(ctx, l)

Expand All @@ -122,6 +125,9 @@ func preCommand(ctx context.Context, cmdName model.TiltSubcommand) context.Conte

ctx = tiltanalytics.WithAnalytics(ctx, a)

// Users don't care about controller-runtime logs.
ctrllog.SetLogger(logr.New(ctrllog.NullLogSink{}))

initKlog(l.Writer(logger.InfoLvl))

// SIGNAL TRAPPING
Expand Down

0 comments on commit c3e3ecc

Please sign in to comment.