Documentation
¶
Overview ¶
Package capture is an auth-internal test helper: a slog.Handler that records log records so tests can assert on auth's logging decisions, plus a helper to install it as the default logger.
It is deliberately auth-internal rather than a dependency on an external logging helper (e.g. slogx/capture): auth is a foundational library, and a ~50-line, never-changing test handler is not worth a new module edge. Import it only from auth's _test.go files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder is a slog.Handler that captures every record regardless of level so tests can assert on what was logged. It is safe for concurrent use.
func Default ¶
Default installs a fresh Recorder as slog's default logger and restores the previous default via tb.Cleanup. Use it for code that logs through slog.Default(); because it mutates global state the test must not run in parallel.
func New ¶
New returns a Recorder and an *slog.Logger writing to it, for code that takes an injected logger. It does not touch the global default, so a test using it may run in parallel.
func (*Recorder) CountMsg ¶
CountMsg returns how many captured records have a message containing sub.
func (*Recorder) Enabled ¶
Enabled reports true for every level so nothing is filtered before capture.