hscontrol/types: silence zerolog by default in tests
Tests were dumping megabytes of zerolog output on failure; silence at init and let individual tests opt in via SetGlobalLevel when they need log-driven assertions. Updates #3157
This commit is contained in:
parent
affaa1a31d
commit
1059c678c4
7 changed files with 66 additions and 156 deletions
18
hscontrol/util/zlog/init_test.go
Normal file
18
hscontrol/util/zlog/init_test.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package zlog
|
||||
|
||||
import "github.com/rs/zerolog"
|
||||
|
||||
// init pins zerolog to TraceLevel for the zlog test binary.
|
||||
//
|
||||
// zlog's tests use zerolog.New(&buf) and assert on Info-level output. zerolog's
|
||||
// (*Logger).should() gates emission on the global level, so any global level
|
||||
// above Info would silently break the assertions.
|
||||
//
|
||||
// Today zlog does not transitively import hscontrol/types, so the test
|
||||
// silencing init() in hscontrol/types/testlog.go does not run in this binary.
|
||||
// This init defends against that changing in the future: if a future import
|
||||
// chain pulls in hscontrol/types, this file will still ensure trace-level
|
||||
// output is available for zlog's assertions.
|
||||
func init() {
|
||||
zerolog.SetGlobalLevel(zerolog.TraceLevel)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue