Help us shape the future of Go! Take the 2026 Go Developer Survey

logs

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Captured

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

func Capture

func Capture(t T) *Captured

func (*Captured) Lines

func (c *Captured) Lines(minLevel slog.Level) []string

func (*Captured) Records

func (c *Captured) Records(minLevel slog.Level) []slog.Record

func (*Captured) String

func (c *Captured) String() string

type Held

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

func Hold

func Hold(notify func(Warned)) *Held

Hold holds back every record slog's default logger gets until Release, as a line written while a terminal UI draws breaks its frame. After a record at WARN or above, Hold calls notify from a goroutine of its own: notify may block, as tea.Program.Send does until the program reads the message, and a record logged in the program's Update would then wait forever, because the program reads the next message only once Update has returned. The records logged while notify blocks are held all the same, and the next call counts them.

func (*Held) Release

func (h *Held) Release(ctx context.Context)

Release restores the logger Hold replaced, and writes every held record to it in order. Release waits for a notify that has not returned yet, so call it once nothing blocks notify any more, such as once tea.Program.Run has returned.

type T

type T interface {
	Helper()
	Name() string
	Setenv(key, value string)
	Cleanup(cleanup func())
}

T is the part of testing.TB that Capture uses, so that the binary does not link package testing.

type Warned

type Warned struct {
	Warnings, Errors int
	Latest           slog.Record
}

Warned counts the records at WARN or above that Hold holds back, so that a terminal UI can show that the log has something to read once it ends.

func (Warned) String

func (w Warned) String() string

String ends with the latest message, so that a view can cut it to its width.

Jump to

Keyboard shortcuts

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