Documentation
¶
Overview ¶
Package spruce providers an slog.Handler that writes pretty-printed structured logs to a testing.T (or compatible) logger.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewStreamHandler ¶ added in v0.2.0
NewStreamHandler returns a new slog.Handler that writes to w.
func NewStreamLogger ¶ added in v0.2.0
NewStreamLogger returns a slog.Logger that writes to w.
func NewTestHandler ¶ added in v0.2.0
NewTestHandler returns a new slog.Handler that writes to t.
func NewTestLogger ¶ added in v0.2.0
NewTestLogger returns a slog.Logger that writes to t.
Types ¶
type Option ¶ added in v0.2.3
type Option func(h *handler)
Option is a function that configures a handler.
func WithAbsoluteTimestamps ¶ added in v0.2.3
func WithAbsoluteTimestamps() Option
WithAbsoluteTimestamps configures a handler to write timestamps as absolute RFC3339 formatted strings.
func WithRelativeTimestamps ¶ added in v0.2.3
func WithRelativeTimestamps() Option
WithRelativeTimestamps configures a handler to write timestamps as relative durations from the time at which the handler was created.
func WithThreshold ¶ added in v0.2.3
WithThreshold configures a handler to only log messages at or above the specified level.
type TestingT ¶
type TestingT interface {
Log(...any)
}
TestingT is the subset of testing.TB that is used to write logs.