refactor, remove winston, implement file-rotation instead #9584
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.
Currently, we use Winston solely for file rotation, while our primary logger is Pino. However, loading Winston during Bit’s bootstrap is costly, adding 94 files to the total (~1,850).
When we initially switched from Winston to Pino, Pino didn't offer a file rotation solution. Now it does -
pino-roll
, which I tested but ended up not using for the following reasons:symlink
option, which doesn't work well with thesync
option that we need. (we tried hard in the past to avoid using sync without success).extension
prop.Since Bit primarily runs as a CLI tool, which initializes fresh with each command, we don’t need real-time log rotation. Instead, we can simply check the log file status at bootstrap and rotate if needed. This is effectively how it works now, with Winston being called only once during bootstrap.
This PR removes Winston and introduces a minimal file rotation mechanism. It rotates the debug.log to a file named "debug-YYYY-MM-DD.log" if it was last modified on a previous day and keeps only the most recent 7 daily logs - executing only once at bootstrap.