fix: wire config logLevel and add 50MB log file rotation (#558)#642
Open
MrRealORG wants to merge 1 commit into
Open
fix: wire config logLevel and add 50MB log file rotation (#558)#642MrRealORG wants to merge 1 commit into
MrRealORG wants to merge 1 commit into
Conversation
) Two fixes for excessive log disk usage: 1. Config logLevel was a dead field — defined in the config schema but never read at runtime. Log.init() only checked the CLI --log-level flag and Installation.isLocal(). Now InstanceBootstrap applies cfg.logLevel from the config file after loading it. 2. No per-file size cap — log files grew unbounded via append-only write stream. Added 50MB max size per file with automatic rotation: when a file exceeds the limit it is rotated (.log.1, .log.2, ... .log.9) and a fresh file is started. Existing file-count cleanup (keeps 10 timestamped logs) continues to work alongside rotation.
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
Addresses #558 (log files growing to 50GB+ in hours) with two fixes:
1. Config `logLevel` was never applied (bug)
The `logLevel` field was defined in the config schema (`config.ts:99`) and documented for users, but never read at runtime. `Log.init()` in `index.ts` only checked the CLI `--log-level` flag and `Installation.isLocal()`. Users who set `"logLevel": "WARN"` in their config file saw no effect.
Fix: Added `Log.setLevel()` export and called it in `InstanceBootstrap` right after config is loaded. CLI `--log-level` still takes precedence (applied first in middleware), but config file now works as a fallback.
2. No per-file size cap (feature)
Log files grew unbounded via `createWriteStream(path, { flags: "a" })`. A single session could produce tens of GB.
Fix: Added 50MB max file size with automatic rotation:
Test Plan