logging: rotate printf log files to cap report size #247

Closed
github-bot wants to merge 4 commits from gh-pr/247/head into gh-pr/247/base
Owner

@⁠Hashim1999164 on GitHub · 2026-08-12 22:13 UTC · original
Hashim1999164:fix/rotating-printf-log → main · +9 −3 · 1 files · 4 commits · closed without merging

Summary

  • Replace unbounded basic_file_sink_mt with rotating_file_sink_mt for printf logs.
  • Cap each file at 64 MiB with 3 rotated files and rotate_on_open=true so verbose titles cannot grow multi-GB logs that are useless for bug reports.

Fixes #200.

Test plan

  • Build with the logging change and start a title that previously produced a huge printf log.
  • Confirm a fresh log file is opened on run and that size stays within the 64 MiB x 3 rotation policy.
  • Confirm existing log viewers still open the active printf log path.
**@⁠Hashim1999164** on GitHub · 2026-08-12 22:13 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/247) `Hashim1999164:fix/rotating-printf-log` → `main` · +9 −3 · 1 files · 4 commits · closed without merging ## Summary - Replace unbounded `basic_file_sink_mt` with `rotating_file_sink_mt` for printf logs. - Cap each file at 64 MiB with 3 rotated files and `rotate_on_open=true` so verbose titles cannot grow multi-GB logs that are useless for bug reports. Fixes #200. ## Test plan - [ ] Build with the logging change and start a title that previously produced a huge printf log. - [ ] Confirm a fresh log file is opened on run and that size stays within the 64 MiB x 3 rotation policy. - [ ] Confirm existing log viewers still open the active printf log path.
Swap the unbounded basic file sink for spdlog rotating_file_sink_mt
(64 MiB x 3) so verbose titles cannot produce multi-GB logs that are
useless for bug reports. Fixes #200.
# Conflicts:
#	src/common/logging/log.cpp
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:14:42 +00:00
github-bot closed this pull request 2026-11-26 09:14:42 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-25 23:16 UTC · original · edited 2026-09-30 17:18 UTC

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 4cfeacdf-f9f9-4d61-86af-6cdb9d6441d5

📥 Commits

Reviewing files that changed from the base of the PR and between b2ca96f423 and e036bd2705.

📒 Files selected for processing (1)
  • src/common/logging/log.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The file logger now uses a rotating sink with a 64 MiB size limit and retains up to three files. The sink rotates on open.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to e036b

Log files are capped at 64 MiB, with the active log and up to three rotated files retained. This matches the stated rotation policy, and no concrete merge blocker remains.

Security Architecture Review

Security architecture risk: 🔵 Low · up to e036b

The change limits log growth without visibly adding privileges or remote access, but preserves historical content that startup previously discarded. Exact disk-use bounds and recovery after interrupted rotation were not fully verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The visible exposure is the configured printf log location and its rotated siblings, under the application's existing filesystem authority. The change does not visibly introduce tenant, service, credential or remote-access scope.

Trust Boundaries and Controls

  • observed — The output path can already be supplied through the command line or launcher configuration. The PR preserves that input route and parent-directory creation; it changes operations within the existing filesystem boundary rather than adding a new path-selection authority.

Resilience and Maintainability Implications

  • inferred — The configured threshold is a disk-growth containment measure, but it is not independently verified as a strict aggregate bound. An earlier inspection of the pinned dependency reports three backups plus the active file for max_files=3; oversized-message handling and partial-rotation recovery remain unresolved.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: rotating printf log files to limit their size.
Description check ✅ Passed The description directly explains the rotating sink, size limits, rotation behavior, motivation, and planned tests.
Linked Issues check ✅ Passed Issue [#200] requires logs to remain usable for reports. src/common/logging/log.cpp replaces the unbounded basic file sink with rotating_file_sink_mt, a 64 MiB per-file limit, and three retained f…
Out of Scope Changes check ✅ Passed The pull request changes only the printf file sink configuration in src/common/logging/log.cpp. The size limit, retention count, native path use, and rotation-on-open behavior support issue [#200] a…

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-25 23:16 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/247#issuecomment-5840945662) · edited 2026-09-30 17:18 UTC <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/247?cs_source=review_comment"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> Navigate logical layers of code changes, visualize relationships, and explore their blast radius. <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml **Review profile**: CHILL **Plan**: Advanced **Run ID**: `4cfeacdf-f9f9-4d61-86af-6cdb9d6441d5` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between b2ca96f423bd6961084e71885ee000e43cb80aa8 and e036bd2705dd492c4dceab2f76f5143aaf9d33fc. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `src/common/logging/log.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The file logger now uses a rotating sink with a 64 MiB size limit and retains up to three files. The sink rotates on open. **Suggested reviewers:** `nmzik` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"e036bd2705dd492c4dceab2f76f5143aaf9d33fc" --> **Change:** Bug fix · **Severity of issue fixed:** Medium <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** _⚪ Minimal_ · up to `e036b` <!-- final_review_risk_coverage:{"sourceCommitId":"e036bd2705dd492c4dceab2f76f5143aaf9d33fc","coveredCommitId":"e036bd2705dd492c4dceab2f76f5143aaf9d33fc","kind":"reviewed"} --> Log files are capped at 64 MiB, with the active log and up to three rotated files retained. This matches the stated rotation policy, and no concrete merge blocker remains. <!-- final_review_risk_end --> <!-- architecture_review_start --> ### Security Architecture Review **Security architecture risk:** _🔵 Low_ · up to `e036b` The change limits log growth without visibly adding privileges or remote access, but preserves historical content that startup previously discarded. Exact disk-use bounds and recovery after interrupted rotation were not fully verified. **Retained concerns** No architecture-level concerns identified. <details> <summary>Security review details</summary> **Security Blast Radius** - _inferred_ — The visible exposure is the configured printf log location and its rotated siblings, under the application's existing filesystem authority. The change does not visibly introduce tenant, service, credential or remote-access scope. **Trust Boundaries and Controls** - _observed_ — The output path can already be supplied through the command line or launcher configuration. The PR preserves that input route and parent-directory creation; it changes operations within the existing filesystem boundary rather than adding a new path-selection authority. **Resilience and Maintainability Implications** - _inferred_ — The configured threshold is a disk-growth containment measure, but it is not independently verified as a strict aggregate bound. An earlier inspection of the pinned dependency reports three backups plus the active file for max_files=3; oversized-message handling and partial-rotation recovery remain unresolved. </details> <!-- architecture_review_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❌ 1</summary> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :----------------: | :--------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ✅ Passed | The title clearly and concisely describes the main change: rotating printf log files to limit their size. | | Description check | ✅ Passed | The description directly explains the rotating sink, size limits, rotation behavior, motivation, and planned tests. | | Linked Issues check | ✅ Passed | Issue [`#200`] requires logs to remain usable for reports. `src/common/logging/log.cpp` replaces the unbounded basic file sink with `rotating_file_sink_mt`, a 64 MiB per-file limit, and three retained f… | | Out of Scope Changes check | ✅ Passed | The pull request changes only the printf file sink configuration in `src/common/logging/log.cpp`. The size limit, retention count, native path use, and rotation-on-open behavior support issue [`#200`] a… | </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=247)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-25 23:16 UTC · original · edited 2026-09-30 10:51 UTC
On src/common/logging/log.cpp line 52 (outdated):

@@ -45,8 +49,14 @@ std::shared_ptr<spdlog::logger> MakeFileLogger(std::string                  name
 		std::filesystem::create_directories(parent);
 	}
 
+<<<<<<< HEAD

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Resolve the merge conflict before building.

<<<<<<< HEAD, =======, and >>>>>>> upstream/main remain in MakeFileLogger. These markers make log.cpp invalid C++, so the target cannot compile. Keep the rotating sink branch and remove the markers and basic-file alternative.

Proposed resolution
-<<<<<<< HEAD
 // rotate_on_open matches the old truncate-on-open "fresh file each run" behavior.
 auto sink = std::make_shared<spdlog::sinks::rotating_file_sink_mt>(
     Common::PathToString(path), kMaxLogFileSize, kMaxLogFiles, true);
-=======
- auto sink =
-     std::make_shared<spdlog::sinks::basic_file_sink_mt>(path.native(), true);
->>>>>>> upstream/main

Also applies to: 56-56, 59-59

✅ Addressed in commit b2ca96f

**@⁠coderabbitai[bot]** on GitHub · 2026-09-25 23:16 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/247#discussion_r4109318219) · edited 2026-09-30 10:51 UTC On `src/common/logging/log.cpp` line 52 (outdated): ```diff @@ -45,8 +49,14 @@ std::shared_ptr<spdlog::logger> MakeFileLogger(std::string name std::filesystem::create_directories(parent); } +<<<<<<< HEAD ``` _🎯 Functional Correctness_ | _🔴 Critical_ | _⚡ Quick win_ **Resolve the merge conflict before building.** `<<<<<<< HEAD`, `=======`, and `>>>>>>> upstream/main` remain in `MakeFileLogger`. These markers make `log.cpp` invalid C++, so the target cannot compile. Keep the rotating sink branch and remove the markers and basic-file alternative. <details> <summary>Proposed resolution</summary> ```diff -<<<<<<< HEAD // rotate_on_open matches the old truncate-on-open "fresh file each run" behavior. auto sink = std::make_shared<spdlog::sinks::rotating_file_sink_mt>( Common::PathToString(path), kMaxLogFileSize, kMaxLogFiles, true); -======= - auto sink = - std::make_shared<spdlog::sinks::basic_file_sink_mt>(path.native(), true); ->>>>>>> upstream/main ``` </details> Also applies to: 56-56, 59-59 <!-- fingerprinting:phantom:triton:serval --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:59b1bbb89f8a108cd5185379 --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commit b2ca96f
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-25 23:16 UTC · original · reviewed

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: c46237e6-9e86-450e-bf44-3b54662122d2

📥 Commits

Reviewing files that changed from the base of the PR and between fd2e15ee73 and 1cd8c672b5.

📒 Files selected for processing (1)
  • src/common/logging/log.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-25 23:16 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/247#pullrequestreview-5323502546) · **reviewed** **Actionable comments posted: 1** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml **Review profile**: CHILL **Plan**: Advanced **Run ID**: `c46237e6-9e86-450e-bf44-3b54662122d2` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between fd2e15ee737ea9a671619246129bc2aae7e0bfda and 1cd8c672b558ad688af9a85f0315ad6d0b2cf096. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `src/common/logging/log.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
Author
Owner

@⁠Hashim1999164 on GitHub · 2026-09-30 10:51 UTC · original

conflict markers are out of log.cpp. kept the rotating sink and dropped the basic file one from upstream. should build now.

**@⁠Hashim1999164** on GitHub · 2026-09-30 10:51 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/247#issuecomment-5909710220) conflict markers are out of log.cpp. kept the rotating sink and dropped the basic file one from upstream. should build now.
Author
Owner

@⁠Hashim1999164 on GitHub · 2026-09-30 17:09 UTC · original

windows failed because spdlog wants a wide filename on that constructor. using path.native() now.

**@⁠Hashim1999164** on GitHub · 2026-09-30 17:09 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/247#issuecomment-5916032518) windows failed because spdlog wants a wide filename on that constructor. using path.native() now.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.