Documentation
¶
Overview ¶
Package logtest points slog's default logger somewhere a test can use. The packages log through slog.Default() rather than an injected logger, so a test reaches their output by swapping the default. It imports nothing from the repository, so every package's tests can use it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is a concurrency-safe log sink: the code under test may log from its own goroutines while the test reads.
func Capture ¶
Capture routes the default logger to the returned Buffer as JSON records at level and above, until the test ends. The default logger is process-wide, so a test that captures must not call t.Parallel: serial tests never overlap the package's parallel ones, which is what keeps another test's lines out of the buffer.