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 ¶
const DefaultTruncate = 2048
DefaultTruncate is the size Truncate uses when n <= 0: 2 KiB (PROTOCOL §10).
const EnvLevel = "ARVEL_LOG_LEVEL"
EnvLevel is the environment variable that selects the log level.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New returns the standard plugin logger: JSON on stderr, level from the environment, attributes plugin and pid.
func ParseLevel ¶
ParseLevel converts debug, info, warn (or warning) and error, in any case, to a slog.Level.
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.