Documentation
¶
Overview ¶
Collecting log/slog handler, usefull for testing.
Index ¶
- type CollectorHandler
- func (h *CollectorHandler) All() []map[string]any
- func (h *CollectorHandler) Enabled(ctx context.Context, level slog.Level) bool
- func (h *CollectorHandler) Handle(ctx context.Context, r slog.Record) error
- func (h *CollectorHandler) Last() map[string]any
- func (h *CollectorHandler) Reset()
- func (h *CollectorHandler) WithAttrs(attrs []slog.Attr) slog.Handler
- func (h *CollectorHandler) WithGroup(name string) slog.Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CollectorHandler ¶
type CollectorHandler struct {
// contains filtered or unexported fields
}
CollectorHandler is a test handler that buffers log entries. This is useful for testing of log output.
func NewTestHandler ¶
func NewTestHandler(level slog.Level, addTime, addSource, addLevel bool) *CollectorHandler
NewTestHandler creates a new BufferHandler.
func (*CollectorHandler) All ¶
func (h *CollectorHandler) All() []map[string]any
All returns all entries that were logged.
func (*CollectorHandler) Last ¶
func (h *CollectorHandler) Last() map[string]any
Last returns the last entry that was logged or an empty map
func (*CollectorHandler) Reset ¶
func (h *CollectorHandler) Reset()
Reset removes all Entries from this test hook.
Click to show internal directories.
Click to hide internal directories.