logx

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Overview

Package logx builds the logger of PROTOCOL §10: JSON lines on stderr with the keys ts, level, msg, plugin and pid, the level taken from ARVEL_LOG_LEVEL, and every string run through a redact.Redactor.

Log call sites should pass strings and errors as attribute values. Other composite values are rendered with %+v and then redacted.

Index

Constants

View Source
const DefaultTruncate = 2048

DefaultTruncate is the size Truncate uses when n <= 0: 2 KiB (PROTOCOL §10).

View Source
const EnvLevel = "ARVEL_LOG_LEVEL"

EnvLevel is the environment variable that selects the log level.

Variables

This section is empty.

Functions

func New

func New(plugin string) *slog.Logger

New returns the standard plugin logger: JSON on stderr, level from the environment, attributes plugin and pid.

func NewWith

func NewWith(plugin string, o Options) *slog.Logger

NewWith is New with explicit options.

func ParseLevel

func ParseLevel(s string) (slog.Level, error)

ParseLevel converts debug, info, warn (or warning) and error, in any case, to a slog.Level.

func Truncate

func Truncate(s string, n int) string

Truncate shortens s to at most n bytes of content, cut at a rune boundary, and appends a marker that says how many bytes were removed. The marker is in addition to the n bytes. n <= 0 selects DefaultTruncate.

Types

type Options

type Options struct {
	// Writer receives the log lines; default os.Stderr.
	Writer io.Writer
	// Level is the minimum level; default is ParseLevel of ARVEL_LOG_LEVEL, or info.
	Level slog.Leveler
	// Redactor scrubs every string; default is a redactor with patterns only.
	Redactor *redact.Redactor
}

Options tunes NewWith; every field is optional.

Jump to

Keyboard shortcuts

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