Skip to main content

Module logging

Module logging 

Source

ConstantsΒ§

MAX_LOG_BYTES πŸ”’
Rotation cap for agentmux-launcher.log (SPEC_WIN10_PAGEFILE_OOM_CRASH_ 2026_06_29 P1). This file mirrors the srv subprocess’s entire stderr stream verbatim, forever, with no rotation of its own β€” left unbounded it grew to 406 MB across 69 days on a real machine, directly tightening the page-file ceiling the pagefile-OOM spec is about. 50 MB per file Γ— 3 rotated files + the live file β‰ˆ 200 MB worst case, versus unbounded.
MAX_PANIC_MSG_CHARS πŸ”’
Longest panic message written to the log. Panic payloads are usually one line, but unwrap() on an error can embed a whole Debug dump.
MAX_ROTATED_FILES πŸ”’

FunctionsΒ§

dirs_fallback_home πŸ”’
Home dir without depending on dirs for THIS specific lookup. Kept to avoid a dirs dep cycle from log() β€” log() is called from data_dir::resolve_paths via failure paths, and we want it to work even if dirs itself is mid-failure.
install_panic_hook πŸ”’
Record every panic in agentmux-launcher.log, then run whatever hook was installed before (the default one, which prints to stderr).
install_panic_hook_with πŸ”’
log πŸ”’
Append a timestamped line to ~/.agentmux/logs/agentmux-launcher.log. Best-effort β€” silently no-ops if the log dir doesn’t exist yet.
panic_line πŸ”’
One log line describing a panic. Kept single-line (the log is read with grep) and bounded, and free of any std panic types so it can be tested.
rotate_if_oversized πŸ”’
Size-based rotation: agentmux-launcher.log -> .log.1 -> .log.2 -> .log.3 (oldest dropped), run once per log() call before appending. A metadata() stat per call is cheap relative to the disk write that follows; simplicity here matters more than shaving a syscall. Best-effort like log() itself β€” any failure (permissions, concurrent access) just leaves the current file growing past the cap rather than losing log data or panicking.
rotated_path πŸ”’