feat(opencode): add pluggable log rotation strategies#12966
Open
Haoping-Xiao wants to merge 7 commits intoanomalyco:devfrom
Open
feat(opencode): add pluggable log rotation strategies#12966Haoping-Xiao wants to merge 7 commits intoanomalyco:devfrom
Haoping-Xiao wants to merge 7 commits intoanomalyco:devfrom
Conversation
Contributor
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
6 tasks
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.
Closes #12960
What
Adds pluggable write strategies to
Log.initso log rotation behavior is configurable without changing default behavior.Two strategies:
startup(default) — existing behavior, one file per startup, retain last 10 filesdaily— one file per day (opencode-YYYY-MM-DD.log), same-day restarts append, retain 7 days by defaultHow
Log.Optionsgets two new optional fields:A
writeStrategiesrecord maps eachkindto its init function. Adding a new strategy = add a type variant + a function.init()dispatches in one line:Env vars for configuration (since Log.init runs before Config loads):
OPENCODE_LOG_PATH— override log directoryOPENCODE_LOG_ROTATE=daily— enable daily rotationOPENCODE_LOG_RETENTION=14— override retention countNot passing anything = zero behavior change.
Verification
bun run typecheck— passesstartupstrategy (default) — same file naming and cleanup as beforeOPENCODE_LOG_ROTATE=daily OPENCODE_LOG_PATH=/tmp/opencode-logs— generatesopencode-2026-02-10.log, appends on restartOPENCODE_LOG_RETENTION=3— correctly keeps newest 3