gosttest

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 5 Imported by: 0

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

type ReplaceAttr func(groups []string, attr slog.Attr) slog.Attr

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL