Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTestingLogger ¶
func NewTestingLogger(t testing.TB, opts ...TestingLogHandlerOption) *slog.Logger
NewTestingLogger creates an *slog.Logger that sends log records to t.
By default, log levels of slog.LevelError or above are reported using t.Error. Levels are reported using t.Log. Error reporting can be suppressed with the AllowErrors option.
By default, log levels below slog.LevelInfo are supressed. This can be customized with the MinLogLevel option.
Types ¶
type ReplaceAttr ¶ added in v0.10.3
func (ReplaceAttr) Chain ¶ added in v0.10.3
func (a ReplaceAttr) Chain(r ReplaceAttr) ReplaceAttr
type TestingLogHandlerOption ¶
type TestingLogHandlerOption = func(*testLogHandlerOptions)
TestingLogHandlerOption is the type of for functional options when creating test loggers using NewTestingLogger
func AllowErrors ¶
func AllowErrors() TestingLogHandlerOption
AllowErrors prevents error level log records from automatically failing a test.
func MinLogLevel ¶
func MinLogLevel(lvl slog.Level) TestingLogHandlerOption
MinLogLevel controls which log level is written. Default is slog.LevelInfo
func WithDisableStack ¶ added in v0.10.3
func WithDisableStack() TestingLogHandlerOption
func WithReplaceAttr ¶ added in v0.10.3
func WithReplaceAttr(r ReplaceAttr) TestingLogHandlerOption
Click to show internal directories.
Click to hide internal directories.