logger

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package logger wraps log/slog so other packages can log without importing slog directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Capture

func Capture(t TestingT, w io.Writer)

Capture swaps the default logger for the duration of the test. The swap is global, so tests calling Capture must not use t.Parallel().

func Debug

func Debug(ctx context.Context, msg string, args ...any)

func Error

func Error(ctx context.Context, msg string, args ...any)

func Info

func Info(ctx context.Context, msg string, args ...any)

func Init

func Init(w io.Writer, level string)

Init installs a logger built from New as slog's process-wide default.

func New

func New(w io.Writer, level string) *slog.Logger

New constructs a JSON logger at the named level. Unknown levels fall back to info; config.Load already rejects anything outside the set, so this branch only triggers if a caller bypasses config validation.

func Warn

func Warn(ctx context.Context, msg string, args ...any)

Types

type TestingT

type TestingT interface {
	Helper()
	Cleanup(fn func())
}

TestingT is the subset of *testing.T that Capture needs, declared here so production builds do not depend on the testing package.

Jump to

Keyboard shortcuts

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