Document kanta.ctx as the app-context channel for logemit

kanta.ctx already existed as a user-writable namespace for migrations;
since LogEvent carries the kanta instance, ev.kanta.ctx is also the way
for applications to pass per-connection metadata to their logemit
callbacks, including for creation/bootstrap events. No API change needed.
This commit is contained in:
Leo Vasanko
2026-08-07 06:04:35 +00:00
parent 799b2438be
commit ecd146f72c
3 changed files with 22 additions and 1 deletions
+3
View File
@@ -235,6 +235,9 @@ def resolve_user_key(value: str) -> str | None:
`kanta` instance, and all relevant state: `action`, `user`, `extra`,
`error` (for aborted transactions), `diff`, `previous`/`current` state
dicts, the built `logfmt` chain, and version info for migration events.
Application-specific context (e.g. a connection id) can be stored in
`kanta.ctx` — a user-writable namespace — and read back in callbacks as
`event.kanta.ctx`, which also covers creation/bootstrap events.
- The built-in formatting is assembled from standard blocks that custom
emitters can reuse as-is or replace piecemeal:
- `event.header` — a lazy property producing the default one-line header