Documentation
¶
Overview ¶
Honestly, got ChatGPT to give me this. Looks reasonable.
Index ¶
- type LogEntry
- type MockHandler
- func (h *MockHandler) Clear()
- func (h *MockHandler) Enabled(_ context.Context, level slog.Level) bool
- func (h *MockHandler) Handle(_ context.Context, record slog.Record) error
- func (h *MockHandler) Logs() []LogEntry
- func (h *MockHandler) MustHaveSeen(t *testing.T, msg string, level slog.Level, attrs map[string]any)
- func (h *MockHandler) WithAttrs(attrs []slog.Attr) slog.Handler
- func (h *MockHandler) WithGroup(_ string) slog.Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockHandler ¶
type MockHandler struct {
// contains filtered or unexported fields
}
MockHandler implements slog.Handler and stores logs in memory.
func NewLogger ¶
func NewLogger() (*slog.Logger, *MockHandler)
func NewMockHandler ¶
func NewMockHandler(level slog.Level) *MockHandler
NewMockHandler creates a new MockHandler.
func (*MockHandler) Clear ¶
func (h *MockHandler) Clear()
Clear removes all stored log entries (useful between tests).
func (*MockHandler) Logs ¶
func (h *MockHandler) Logs() []LogEntry
Logs returns a snapshot of all log entries.
func (*MockHandler) MustHaveSeen ¶
Click to show internal directories.
Click to hide internal directories.