Commit Graph

2 Commits

Author SHA1 Message Date
82e7f4398b fix(logger): render full logfmt line as journal MESSAGE
The native journal handler only put the bare msg string in MESSAGE,
so default `journalctl` output lost all slog attributes (env, name,
ip_version, etc.) that were visible with the old TextHandler path.

Wrap the slog-journal handler so each record's MESSAGE is rendered
through slog.TextHandler — producing the same `level=INFO msg="..."
key=val` format as before — while still emitting every attribute as
a structured journal field for `journalctl -o verbose` / field-based
filtering.

Also fix go.mod: slog-journal is a direct dependency.
2026-04-19 02:06:29 -07:00
d8b9cddfb8 feat(logger): deliver stderr to systemd journal with per-record priority
When stderr is connected to journald, switch from the plain text handler
to the native journal protocol via github.com/systemd/slog-journal. Each
record now carries PRIORITY, MESSAGE, and slog attributes as structured
fields, so journalctl -p and LogLevelMax= in unit files filter by
severity instead of dropping everything at once.

Detection follows systemd.exec(5): parse JOURNAL_STREAM as <dev>:<ino>
and fstat(2) stderr to confirm the match, guarding against processes
that inherit the env var but have stderr redirected elsewhere. The
fstat path is Linux-only; other platforms fall through to the existing
text handler.

Also honour DEBUG_INVOCATION by raising stderr to Debug level, matching
the behaviour of systemd.service(5) RestartMode=debug.
2026-04-12 14:01:07 -07:00