Final cleanup: lazy logfmt build, docstring and example fixes

- transaction.py only builds the logfmt chain when logging is enabled
- callbacks.py module docstring documents the logemit special case
- docs logemit example uses the settable header instead of a user lookup
  that would break when logfmt resolution is registered
This commit is contained in:
Leo Vasanko
2026-08-07 06:17:17 +00:00
parent ecd146f72c
commit 47f38f4a71
3 changed files with 8 additions and 4 deletions
+3 -3
View File
@@ -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