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:
parent
fe27fea2ae
commit
f202007843
@ -3,6 +3,7 @@ package tester
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
@ -33,7 +34,17 @@ func StubRootCmd(args ...string) *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewContext() (context.Context, func()) {
|
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) }
|
return ctx, func() { logger.Flush(ctx) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user