Commit Graph
16 Commits
Author SHA1 Message Date
Leo Vasanko cc319ce065 Include 'by user' in abort messages
The aborted event now carries the transaction user, resolved through the
logfmt chain against the pre-transaction state so it matches change
headers. Default rendering: '<action> by <user> transaction aborted: <e>'.
User resolution factored into _build_logfmt/_resolve_user helpers shared
by the change and abort paths.
2026-08-07 05:45:31 +00:00
Leo Vasanko 79faa220df Route transaction aborts through logemit as 'aborted' events
The rollback warning is now a LogEvent (kind='aborted', WARNING level,
carrying the exception) dispatched via emit_event so logemit callbacks can
handle or restyle it. Default rendering: action in transaction color
without quotes, followed by ' transaction aborted: {exc}' in default
color.
2026-08-07 05:40:01 +00:00
Leo Vasanko 54d01f1e74 Fortify logging: no logging failure may break functionality
emit_event now swallows and reports any failure, including crashes in the
built-in default_emit formatting itself; log_change routes through it.
logfmt chain callbacks that raise are logged and treated as fall-through,
and logmigr callbacks get on_error reporting like fatal_error handlers,
so a broken logging callback can no longer abort a transaction or open.

Demo: raw user ids in v0 logs, logfmt-resolved names in v1 logs.
2026-08-07 05:23:33 +00:00
Leo Vasanko 6eb9087863 Add logemit event callbacks and kanta.tty terminal formatting
All change-related output (transactions, bootstrap, migrations) is now
described by a mutable LogEvent carrying full state plus the preferred
logger and level, and dispatched through emit_event. @kanta.logemit
callbacks receive the event and decide what is logged where: falsy return
marks it handled, truthy passes it (possibly modified) down the chain,
with default_emit - Kanta's own formatting, now just another emitter - as
the fallback. Pretty header and diff lines are lazy event properties.

New kanta.tty module: Line builder (call to append content, .colorname
arms a palette color for the next call with automatic folded reset,
width/align padding), a mutable Colors palette storing bare SGR params
(0 clears, sequential last-wins stacking), and strip_ansi/displaywidth/pad
helpers that count wide chars and emoji correctly.
2026-08-07 05:11:54 +00:00
Leo Vasanko e42f81f44f Replace log dict toggles with logdiff kwarg and kanta.transaction.diff logger
Per-transaction logdiff=False skips building and printing the diff body,
logging only the header. Globally, configure_logging(diff=False) disables
the kanta.transaction.diff child logger, which now carries all diff lines,
so applications can route or silence diffs separately from headers.
2026-08-07 01:26:50 +00:00
Leo Vasanko 9e19a1bf21 Remove logheader callback feature; keep Kanta-colored extra string in default header 2026-08-07 00:44:06 +00:00
Leo Vasanko 1cd99aef01 Demo: plain-text custom header colored by Kanta, rename migration, str extras 2026-08-07 00:33:56 +00:00
Leo Vasanko 5d66d423da Lazy clock reads; demo: auto-advancing +1h clock, module-level setup 2026-08-07 00:01:16 +00:00
Leo Vasanko 8d9e948d27 Demo: deterministic clock, # section banners, .kantadb extension, raw record dump 2026-08-06 23:57:00 +00:00
Leo Vasanko 450952cd64 Document transaction log headers: extra, logheader, toggles 2026-08-06 23:07:05 +00:00
Leo Vasanko c1d01d3b1c Fix creation of new database, ensuring that a bootstrap record of the initial state is always written. 2026-06-15 00:32:54 +00:00
Leo Vasanko 3e6210d0e9 Add read only mode that doesn't use locking. Useful for inspection while the database is in use or when no changes are intended (except in RAM). 2026-06-14 19:35:06 +00:00
Leo Vasanko 384b4fba4f Improved log formatting support by @kanta.logfmt, which replaces old resolver and user_display arguments (breaking change). 2026-06-13 21:22:05 +00:00
Leo Vasanko 7a74662df0 Implement proper bootstrap and fatal error handling via decorators. Breaks compatibility. 2026-06-13 02:58:29 +00:00
Leo Vasanko 74150b783c Proper ts/mtime setting and tracking. Added Kanta.mtime property for reading current change time. 2026-06-13 00:49:35 +00:00
Leo Vasanko afebad72df Initial commit 2026-06-12 19:18:15 +00:00