Skip to main content

gc_log_directory

Function gc_log_directory 

Source
pub fn gc_log_directory()
Expand description

Best-effort sweep of stale files in {cache_dir}/logs/.

Catches every log type that lands in this directory — not just daemon-spawn-*.log. As of the issue-#323 fix this includes:

  • daemon-spawn-{pid}-{nanos}.log (per-spawn daemon stdio capture; CLI-owned)
  • daemon-lifecycle.log.1 (rotated lifecycle archive; the daemon handles its own 1 MiB soft-cap but never garbage-collects the archive, so it can sit on disk forever after the daemon exits)
  • daemon.log.* (rotated event-log archives; the EventLogger keeps N by count, this adds a time-based safety net for archives left behind by daemons that exited before the next rotation)
  • compile_journal.jsonl.* (rotated compile-journal archives; same rationale)
  • Anything else that may have accumulated here from past versions or external tooling

The active daemon-lifecycle.log is intentionally preserved — a long-idle daemon may go 24h between writes (spawn → next event), and deleting it mid-life would erase the very history that #323 needed to diagnose the multi-spawn bug.