Skip to content

Commit c66c912

Browse files
committed
should print max information by default
When tests do not fail, what they printed rarely matters. However, when they do fail, it is important to see maximum information. This change switches default behavior back as was in 0.31, when failures could be quickly triaged without adding -v
1 parent 9895e2e commit c66c912

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

log/logger.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,17 @@ type Logger interface {
1919
Printf(format string, v ...any)
2020
}
2121

22-
// defaultLogger is the default Logger instance.
23-
var defaultLogger Logger = &noopLogger{}
22+
// defaultLogger would print available information to stderr
23+
var defaultLogger Logger = log.New(os.Stderr, "", log.LstdFlags)
2424

2525
func init() {
2626
// Enable default logger in the testing with a verbose flag.
2727
if testing.Testing() {
28-
// Parse manually because testing.Verbose() panics unless flag.Parse() has done.
28+
// Disble logging if explicitly disabled via -test.v=false
2929
for _, arg := range os.Args {
30-
if strings.EqualFold(arg, "-test.v=true") || strings.EqualFold(arg, "-v") {
31-
defaultLogger = log.New(os.Stderr, "", log.LstdFlags)
30+
if strings.EqualFold(arg, "-test.v=false") {
31+
defaultLogger = &noopLogger{}
32+
break
3233
}
3334
}
3435
}

0 commit comments

Comments
 (0)