Compare commits

..
2 Commits
Author SHA1 Message Date
sneak f22461fe25 Emit slog attributes from every handler (closes #19)
check / check (push) Successful in 36s
check / check (pull_request) Successful in 35s
Handle never read the record's attributes, and WithAttrs and WithGroup
returned the receiver unchanged. The JSON and webhook handlers also marshaled
slog.Record itself, whose attributes are unexported.

Each handler now carries a handlerAttrs value, copied rather than mutated, so
sibling loggers cannot leak attributes into each other. JSON and webhook
output nest groups as objects; the console appends key=value pairs with dotted
group keys, quoted as slog.NewTextHandler quotes them. Logged values are never
written to. In JSON the record's own fields win a key collision, and a
repeated key keeps its last value unless both are groups, which merge; the
README documents both.

Deviation: a key containing invalid UTF-8 stays unquoted, unlike the stdlib:
#24.

Model: opus-5-5 (rebase, this message)
2026-09-28 10:34:46 +00:00
sneak 5d4b078304 Add a failing test pinning the discarded slog attributes
Every handler drops slog attributes: Handle never reads the record's
attributes, and WithAttrs and WithGroup return the receiver unchanged. So
slog.Info("casting", "device", d) loses its field.

The test checks the bytes each handler writes, directly and through
MultiplexHandler: record attributes, WithAttrs, WithGroup, slog.Group nesting
and LogValuer resolution. It also pins what a fix must not break: logged values
are never modified, durations are nanoseconds in JSON and "3s" on the console,
console keys are quoted like values, and the record's own field names win a key
collision.

This commit adds only the test, and it fails; the fix follows.

Rule suppressed: paralleltest, because the tests swap the process-wide
os.Stdout.

Refs: #19

Model: opus-5-5 (rebase, this message)
2026-09-28 10:34:46 +00:00

Diff Content Not Available