fix(cli): add log rotation for fern docs dev debug logs#14758
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
🌱 Seed Test SelectorSelect languages to run seed tests for:
How to use: Click the ⋯ menu above → "Edit" → check the boxes you want → click "Update comment". Tests will run automatically and snapshots will be committed to this PR. |
| this.initialized = true; | ||
|
|
||
| // Enforce the 100 MB cap on the logs directory | ||
| await this.enforceLogSizeLimit(logsDir); |
There was a problem hiding this comment.
dont await, run in bg
There was a problem hiding this comment.
Good call — changed to void this.enforceLogSizeLimit(logsDir) so it runs fire-and-forget without blocking startup.
| * Delete oldest log files until total directory size is within the cap. | ||
| */ | ||
| private async enforceLogSizeLimit(logsDir: AbsoluteFilePath): Promise<void> { | ||
| try { |
There was a problem hiding this comment.
add a debug log here "rotating logs" or something like that
There was a problem hiding this comment.
Added a log_rotation debug entry that logs total size, file count, and the cap before deletion starts.
Enforce a 100 MB cap on ~/.fern/logs/. On each fern docs dev startup, the DebugLogger now scans the logs directory and deletes the oldest .log files until total size is within the limit. Closes FER-9568 Co-Authored-By: Sandeep Dinesh <sandeep@buildwithfern.com>
Co-Authored-By: Sandeep Dinesh <sandeep@buildwithfern.com>
Co-Authored-By: Sandeep Dinesh <sandeep@buildwithfern.com>
Co-Authored-By: Sandeep Dinesh <sandeep@buildwithfern.com>
8e6aafe to
71be4a0
Compare
Co-Authored-By: Sandeep Dinesh <sandeep@buildwithfern.com>
…rver Co-Authored-By: Sandeep Dinesh <sandeep@buildwithfern.com>
Co-Authored-By: Sandeep Dinesh <sandeep@buildwithfern.com>
Co-Authored-By: Sandeep Dinesh <sandeep@buildwithfern.com>
…allback Co-Authored-By: Sandeep Dinesh <sandeep@buildwithfern.com>
Description
Closes FER-9568
fern docs devwrites debug logs to~/.fern/logs/but never cleans them up, causing unbounded disk usage over time. This adds automatic log rotation with a 100 MB directory size cap.Changes Made
enforceLogSizeLimit()private method inDebugLoggerthat runs fire-and-forget at the end ofinitialize()consoleLoggercallback parameter toDebugLogger.initialize()so rotation status is logged to the console (debug when under cap, info when rotating) — wired tocontext.loggerinrunAppPreviewServer.tsfern docs devflowversions.ymlentry (4.63.2, fix)Review Checklist
file.fullPath === this.logFilePathcomparison:this.logFilePathis anAbsoluteFilePath(branded string), whilefile.fullPathis built withpath.join()(plain string). Works at runtime sinceAbsoluteFilePathisstring & { __AbsoluteFilePath: void }, but verify paths are normalized consistently.void) — does not block startupTesting
biome check)--log-level=debugLink to Devin session: https://app.devin.ai/sessions/0212b2e6da7543248d179fb0d4f0450a
Requested by: @thesandlord