feat: rotate debug logs at 128 MB or 30 days - #15
Merged
Conversation
Prevent unbounded JSONL growth by rotating the active debug log before startup and each write when size or age limits are exceeded.
Express debug log size limits in megabytes (default 128) for simpler TOML.
- Use OsString manipulation for the backup path so non-UTF-8 paths round-trip. - Document max_log_mb, max_log_age_days, and per-instance log_path guidance. - Add age-based rotation integration test. - Treat max_log_mb = 0 and max_log_age_days = 0 as invalid (fallback to defaults). - Fix clippy collapsible_if warning in DebugLog::new. - Clean up temp directories on test panic via TempDirGuard. Signed-off-by: jatmn <the@jat.mn>
Use file creation time for age limits when available, rotate through a staging file so backup removal failures do not drop the active log, reject directory log paths, and document age semantics in configuration.
jatmn
force-pushed
the
feat/debug-log-rotation
branch
from
August 6, 2026 03:25
669907d to
d4cc951
Compare
…emantics Restore or promote orphaned `.rotating` staging files after a crash so segments are not discarded on the next rotation, and clarify that mtime-only filesystems only age-rotate idle logs.
Promote staged segments through a pending backup path and only retire the
previous {log_path}.1 after the new backup rename succeeds, so a failed
promotion restores both the active segment and the prior backup.
Finish or roll back orphaned {log_path}.1.new and {log_path}.1.old
states after a crash between promotion renames instead of deleting
them on the next rotation. Add regression tests for pending-only and
pending-plus-retired recovery paths.
Validated with cargo fmt --check, cargo test --locked.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
{log_path}.1and starts a fresh log file.debug.max_log_mbanddebug.max_log_age_days.Test plan
cargo test