entryhuman

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package entryhuman contains the code to format slog.SinkEntry for humans.

Index

Constants

View Source
const TimeFormat = "2006-01-02 15:04:05.000"

TimeFormat is a simplified RFC3339 format.

Variables

This section is empty.

Functions

func Fmt

func Fmt(buf *bytes.Buffer, termW io.Writer, ent slog.SinkEntry)

Fmt returns a human readable format for ent. Assumes we have a bytes.Buffer which we will more easily be able to assume underlying reallocation of it's size is possible if necessary than for an arbitrary io.Writer/io.StringWriter Note that while bytes.Buffer can in theory return an error for writes, it only does so if the buffer size will exceed our architectures max integer size. If the system is actually OOM and more memory cannot be allocated it will panic instead.

We never return with a trailing newline because Go's testing framework adds one automatically and if we include one, then we'll get two newlines. We also do not indent the fields as go's test does that automatically for extra lines in a log so if we did it here, the fields would be indented twice in test logs. So the Stderr logger indents all the fields itself.

func StripTimestamp

func StripTimestamp(ent string) (time.Time, string, error)

StripTimestamp strips the timestamp from entry and returns it and the rest of the entry.

Types

type Formatter

type Formatter struct {
	ErrorCallback func(slog.Field, error)
}

func (Formatter) Fmt

func (f Formatter) Fmt(buf *bytes.Buffer, termW io.Writer, ent slog.SinkEntry)

Jump to

Keyboard shortcuts

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