From f202007843d8129d18ea1455f5016b4203c7878c Mon Sep 17 00:00:00 2001 From: Keepers Date: Tue, 20 Dec 2022 15:23:28 -0700 Subject: [PATCH] debug logs only if testing with -v (#1870) ## Description Log tests at info level normally. If debug logs are wanted, the tester can call -v. ## Type of change - [x] :hamster: Trivial/Minor --- src/internal/tester/cli.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/internal/tester/cli.go b/src/internal/tester/cli.go index beeda5946..cee5a8f0f 100644 --- a/src/internal/tester/cli.go +++ b/src/internal/tester/cli.go @@ -3,6 +3,7 @@ package tester import ( "context" "fmt" + "os" "time" "github.com/google/uuid" @@ -33,7 +34,17 @@ func StubRootCmd(args ...string) *cobra.Command { } func NewContext() (context.Context, func()) { - ctx, _ := logger.SeedLevel(context.Background(), logger.Development) + level := logger.Info + + for _, a := range os.Args { + if a == "-test.v=true" { + level = logger.Development + } + } + + //nolint:forbidigo + ctx, _ := logger.SeedLevel(context.Background(), level) + return ctx, func() { logger.Flush(ctx) } }