loggingtest

package
v0.56.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package loggingtest builds redacting loggers for tests, writing to a buffer the test reads back.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	// contains filtered or unexported fields
}

Buffer collects log output, safely from several goroutines.

func New

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

New returns a redacting logger, as logging.New makes it, keyed with a dummy key and writing to the returned buffer.

func (*Buffer) Lines

func (b *Buffer) Lines(t testing.TB) []map[string]any

Lines decodes every JSON line written, in order. A line that is not JSON fails the test.

func (*Buffer) String

func (b *Buffer) String() string

String returns everything written.

func (*Buffer) Write

func (b *Buffer) Write(p []byte) (int, error)

Write appends p.

Jump to

Keyboard shortcuts

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