per-run-log-pid-suffix#1783
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the TUI logging strategy by appending the process ID to the log filename, which prevents log clobbering when multiple instances are running simultaneously. Review feedback highlights that this change may lead to excessive log accumulation and recommends implementing a pruning mechanism for old logs, as well as updating the module documentation to reflect the new behavior.
| let log_path = log_dir.join(format!("tui-{date}.log")); | ||
| // Per-run suffix avoids multiple concurrent TUI instances writing to the | ||
| // same file. Process ID is unique enough per boot. | ||
| let log_path = log_dir.join(format!("tui-{date}-{}.log", std::process::id())); |
There was a problem hiding this comment.
Including the PID in the log filename prevents concurrent TUI instances from clobbering the same log file. However, this change introduces a few concerns:\n\n1. Log Accumulation: This shifts the logging strategy from 'daily-rolling' to 'per-run'. Without an automated pruning mechanism (similar to the one used for spillover files in main.rs), this will lead to an unbounded accumulation of log files in ~/.deepseek/logs/ over time.\n2. Documentation Mismatch: The module-level documentation (lines 1-4) still describes the logging as 'daily-rolling', which is now inaccurate.\n\nConsider implementing a pruning task to remove logs older than a certain threshold (e.g., 7 days) to maintain disk health.
|
Good point about log accumulation. Two thoughts: 1. This isn't a new problem. The existing single-file approach already accumulates — the old 2. Pruning is a separate concern. I've opened Issue #1784 to track it. Proposed: delete logs older than 7 days (configurable via env, 7-day default). That's the right scope for a follow-up PR rather than blocking this one-liner. I'll push a doc update to the module comment now. |
Problem
Multiple concurrent TUI instances write to the same log file (
tui-YYYY-MM-DD.log), causing interleaved entries and file contention.Fix
Append process ID to log filename:
tui-YYYY-MM-DD-<PID>.log.One line change in
crates/tui/src/runtime_log.rs.Closes #1782