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] 🐹 Trivial/Minor
This commit is contained in:
Keepers 2022-12-20 15:23:28 -07:00 committed by GitHub
parent fe27fea2ae
commit f202007843
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) }
}