Documentation
¶
Overview ¶
Package logtest captures slog output in tests.
Index ¶
- type Logs
- func (c *Logs) AttrsFor(level slog.Level, msg string) []map[string]any
- func (*Logs) Enabled(context.Context, slog.Level) bool
- func (c *Logs) Handle(_ context.Context, r slog.Record) error
- func (c *Logs) LogCount(level slog.Level, msg string) int
- func (c *Logs) RecordsAt(level slog.Level) []map[string]any
- func (c *Logs) WarnsFor(clientID string) []map[string]any
- func (c *Logs) WithAttrs([]slog.Attr) slog.Handler
- func (c *Logs) WithGroup(string) slog.Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logs ¶
type Logs struct {
// contains filtered or unexported fields
}
Logs records slog output for assertions.
func Capture ¶
Capture swaps slog's global default for a recorder until the test ends. Tests using it must not call t.Parallel, since the default is process-wide.
func (*Logs) AttrsFor ¶
AttrsFor returns the attributes of every captured record of the given level and message.
func (*Logs) LogCount ¶
LogCount returns how many records of the given level and message were captured.