logger

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HookedLoggerBuilder

func HookedLoggerBuilder(t testing.TB, hook func(ctx context.Context, r slog.Record)) func(*logger.LogConfiguration) (*slog.Logger, error)

HookedLoggerBuilder creates logger which sends every log message also to "hook".

func LoggerBuilder

func LoggerBuilder(t testing.TB) func(*logger.LogConfiguration) (*slog.Logger, error)

LoggerBuilder returns "logger factory" for test t.

Factory function returned by LoggerBuilder returns the same logger for all calls.

func NOP

func NOP() *slog.Logger

NOP returns a logger which doesn't log (ie /dev/null). Use it for tests where valid logger is needed but it's output is not needed.

func New

func New(t testing.TB) *slog.Logger

New returns logger for test t on debug level.

func NewLoggerHook

func NewLoggerHook(h slog.Handler, hook func(ctx context.Context, r slog.Record)) *logHandler

func NewLvl

func NewLvl(t testing.TB, level slog.Level) *slog.Logger

NewLvl returns logger for test t on level "level".

First part of the log line is source location which is invalid for messages logged by the logger (they are correct for the t.Log, t.Error etc calls). Fix needs support from the Go testing lib (see https://github.com/golang/go/issues/59928).

Types

This section is empty.

Jump to

Keyboard shortcuts

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