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:
Kristoffer Dalby 2026-04-15 08:28:11 +00:00
parent affaa1a31d
commit 1059c678c4
7 changed files with 66 additions and 156 deletions

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