wordcraft/apps
Gert Pellin - GPE 9b6f42dd5f
Desktop: write log records to standard error and a rotating log file (#17)
* Desktop: write log records to standard error and a rotating log file

The desktop app installed no logger, so every log::warn!/log::error! in
the workspace was discarded: an unreadable part of a .docx, a picture or
font a PDF export had to leave out, a PNG that would not encode. A launch
from a desktop menu has no terminal either, and a panic's message went to
that missing terminal, so there was nothing to attach to a bug report.

apps/wordcraft/src/logging.rs (no new dependency):
- standard error plus logs/wordcraft.log next to the preferences
  (~/.config/wordcraft/logs, or under $XDG_CONFIG_HOME); each launch
  rotates the previous log to wordcraft.1.log and .2.log, so the log of
  a run that crashed survives the next start; the file is capped at 16 MiB
- records logged before the settings directory is known are buffered
  (bounded) and written once the file is attached
- default levels: info for wordcraft*, warn for everything else;
  RUST_LOG replaces them with env_logger-style directives
- never panics: an unusable directory or a failed write leaves standard
  error as the only sink
- runs with WORDCRAFT_NO_PREFS (agents' test runs) log to standard error
  only, so they don't rotate away the user's own logs
- a panic hook reports every panic, also those Session::run's guard
  recovers from, through the logger; text the message quotes between
  backticks (std quotes the string it failed to slice, which can be the
  user's writing) is left out

The logger is installed first in main, before the panic hook, and the
file is opened after argument parsing (--version leaves no file). The
control server's and file-open messages go through the logger and drop
their "wordcraft: " prefix, which the record's target now shows.
Documented in README.md (Logs).

* Desktop: no eprintln! on the log and panic paths

eprintln! panics when standard error is a broken pipe (a GUI launch on
Windows), and a panic inside the panic hook aborts. The "no log file"
message goes through log::warn! (standard error only by then); the panic
hook's fallback writes to standard error with write_fmt and ignores the
error. Same fix as storytold/vectorcraft#465.

---------

Co-authored-by: Brandon Thomas <shared2@storyteller.ai>
2026-10-09 09:22:04 -04:00
..
wordcraft Desktop: write log records to standard error and a rotating log file (#17) 2026-10-09 09:22:04 -04:00
wordcraft-cli Layout: text wrap around floating objects, text box contents, page borders (from page edge), column separators, vertical alignment, line numbers; cli run --page/--scale 2026-10-06 01:04:48 -04:00
wordcraft-web Clippy/fmt clean workspace, ROADMAP with honest parity estimate; xtask ci green 2026-10-06 00:11:08 -04:00