Files
headscale/hscontrol/util/zlog/init_test.go
Kristoffer Dalby 1059c678c4 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
2026-04-17 16:31:49 +01:00

19 lines
732 B
Go

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