fix(ops): 为 openless.log 增加启动轮转#309
Merged
Merged
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8ef0d4b96e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
PR Reviewer Guide 🔍(Review updated until commit 275a11e)Here are some key observations to aid the review process:
|
Long-running tray installs can accumulate an unbounded openless.log. Startup now checks the current log after single-instance arbitration but before simplelog opens the file, then rotates files over 10 MiB to openless.log.1. Normal append logging resumes with a fresh current log and log export continues to copy only openless.log. Rotation remains best-effort: startup continues if archive cleanup or rename fails, but stderr receives an explicit warning so the failure is diagnosable even before the file logger is initialized. Boundary tests cover oversized, small, and missing log files. Constraint: Issue Open-Less#303 asks for a minimal startup size check with openless.log.1 archive. Constraint: Duplicate macOS/Linux launches must exit before rotation so they cannot rename the owning instance's active log file. Rejected: Add tracing-appender rolling support | new dependency and wider logging rewrite for a low-risk ops fix. Rejected: Add platform-specific rotation-failure tests | brittle across Linux/macOS/Windows file locking semantics. Confidence: high Scope-risk: narrow Directive: Keep export_error_log focused on openless.log; do not include rotated archives unless product explicitly asks for history export. Directive: Keep log rotation best-effort; startup must continue even if archive cleanup or rename fails. Tested: cargo test --manifest-path src-tauri/Cargo.toml log_ Tested: cargo check --manifest-path src-tauri/Cargo.toml Tested: git diff --check Not-tested: Manual startup rotation on Windows/macOS. Related: Open-Less#303
8ef0d4b to
275a11e
Compare
|
Persistent review updated to latest commit 275a11e |
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.
User description
变更
openless.log大小,超过 10 MiB 时轮转为openless.log.1openless.log,不包含历史归档验证
cargo test --manifest-path src-tauri/Cargo.toml log_cargo check --manifest-path src-tauri/Cargo.tomlgit diff --checkCloses #303
PR Type
Enhancement, Bug fix
Description
Rotate
openless.logon startup if > 10 MiBArchive to
openless.log.1, delete old archiveMove logger init to
setupto avoid duplicate rotationAdd tests for rotation, small, and missing log
Diagram Walkthrough
flowchart LR A["App startup"] --> B["Check openless.log size"] B --> C{"Size > 10 MiB?"} C -- Yes --> D["Remove old archive openless.log.1"] D --> E["Rename current log to archive"] E --> F["Initialize file logger"] C -- No --> F F --> G["Append new logs"]File Walkthrough
lib.rs
Implement startup log rotation to cap openless.log at 10 MiBopenless-all/app/src-tauri/src/lib.rs
LOG_ROTATE_LIMIT_BYTES(10 MiB)rotate_log_if_too_largeto archive oversized loginit_file_logger, warning on failureinit_file_loggertosetupclosure after single‑instance checkis no‑op