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 TestingLogHandlerOption ¶
type TestingLogHandlerOption = func(*testingLogHandler)
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
Click to show internal directories.
Click to hide internal directories.