slogt

package
v0.4.48 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package slogt integrates testing and log/slog together.

Use of this package means that structured logs produced either by a test of the code under test can be emitted to the test's output. This improves debuggability, as the log output is now attached to the test that caused it to be emitted.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSON

func JSON(tb TB) *slog.Logger

JSON wraps JSONWithOptions with default (nil) options.

func JSONWithOptions

func JSONWithOptions(tb TB, options *slog.HandlerOptions) *slog.Logger

JSONWithOptions creates a new logger using a JSON handler and default options.

func New

func New(tb TB) *slog.Logger

New is an alias for Text.

func Text

func Text(tb TB) *slog.Logger

Text wraps TextWithOptions with default (nil) options.

func TextWithOptions

func TextWithOptions(tb TB, options *slog.HandlerOptions) *slog.Logger

TextWithOptions creates a new logger using a text handler and the given options.

Types

type TB added in v0.4.36

type TB interface {
	Helper()
	Output() io.Writer
}

TB is a selection of the methods provided by testing.TB.

Jump to

Keyboard shortcuts

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