diff --git a/docs/database.md b/docs/database.md index fb99602..06c8e9f 100644 --- a/docs/database.md +++ b/docs/database.md @@ -269,9 +269,9 @@ def resolve_user_key(value: str) -> str | None: def emit(ev: LogEvent): if ev.kind != "change": return default_emit(ev) # delegate, no chaining needed - actor = ev.current.get("users", {}).get(ev.user, {}).get("name", ev.user) - line = Line().user(actor, width=20)(" ").action(ev.action) - ev.logger.log(ev.level, f"{line}\n" + "\n".join(ev.diff_lines)) + # Restyle the header; default_emit keeps routing the diff body. + ev.header = str(Line().user(ev.user or "-", width=20)(" ").action(ev.action)) + return True ``` #### Terminal Formatting Helpers diff --git a/kanta/callbacks.py b/kanta/callbacks.py index 5cf6dd1..034e997 100644 --- a/kanta/callbacks.py +++ b/kanta/callbacks.py @@ -7,6 +7,10 @@ default value. Log formatters are a special case: they are called per value being rendered and receive the value plus an optional ``path`` string. They return ``str | None``; ``None`` means "fall through to the next formatter". + +Log emitters (``logemit``) are another special case: plain callables that +receive a :class:`kanta.logging.LogEvent` and are dispatched by +:func:`kanta.logging.emit_event`. """ from __future__ import annotations diff --git a/kanta/transaction.py b/kanta/transaction.py index f947bed..bb56008 100644 --- a/kanta/transaction.py +++ b/kanta/transaction.py @@ -90,8 +90,8 @@ def transaction( previous = impl.statedict record = impl.queue_change(action, new_dict, user=user, mtime=mtime) if record is not None: - logfmt = _build_logfmt(impl, previous, new_dict) if log is not False: + logfmt = _build_logfmt(impl, previous, new_dict) logger = ( log if isinstance(log, logging.Logger) else transaction_logger )