Skip to main content

Module logging

Module logging 

Source
Expand description

Logging: always-on JSONL, optional file log, crash reports.

Layout under [Config::data_dir]:

<data_dir>/
  logs/unified.jsonl    # structured events (append-only)
  crash/crash-*.txt     # panic reports
  debug/whycodes-*.log   # --debug / WHYCODES_LOG_FILE human logs
  debug/latest.log      # symlink (or copy) of the active debug log

Environment:

  • RUST_LOG / WHYCODES_LOG_LEVEL — filter (e.g. debug, info,whycodes_agent=debug)
  • WHYCODES_LOG_FILE — extra human-readable log path (verbatim)
  • RUST_BACKTRACE — included in crash reports when set

Structs§

InitOptions
Options for init.
LogDirs
Standard log / crash / debug directories under the data dir.
LogEvent
One line of logs/unified.jsonl.
LoggingHandle
Handle returned by init (cloneable path info).

Functions§

append_jsonl
Append a single JSON line to path (creates parent dirs as needed).
clear_panic_cleanup
Clear the panic cleanup callback (e.g. after clean TUI exit).
dirs
Current log directories if init has run.
emit
Emit a structured event to the process-wide unified.jsonl (no-op if not init’d).
emit_sid
Like emit but attaches a session id.
format_crash_report
Build crash report text (no I/O). Public for tests.
init
Initialize process logging. Safe to call once; subsequent calls return the existing handle without re-installing the subscriber.
is_initialized
Whether logging has been initialized.
set_panic_cleanup
Register a cleanup callback (e.g. leave alternate screen) run before crash I/O.
write_crash_report
Format and write a crash report. Public for tests.