Repository navigation
Conversation
Resolve each configured path once per logger and keep the original route lists. This keeps Zap internal diagnostics in the active file and accounts for duplicate writes against one size limit. Signed-off-by: cwj2001 <74065082+cwj2001@users.noreply.github.com>
cwj2001
requested review from
Pangjiping,
hittyt,
hpliStartAgain,
jwx0925 and
ninan-nn
as code owners
November 26, 2026 06:28
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This branch has not been deployed
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
With one configured log file, Zap's internal error output defaults to the same path as ordinary output. Each route previously opened its own rotating writer. Once both writers were open, rotation on the ordinary route could leave internal diagnostics going to the renamed backup instead of the active file. Repeating an output path could also cause the writers to undercount the bytes written to that file.
Reuse the writer for each identical path string within a logger instance. This shares the file handle and size counter without removing any configured copies. It does not change rotation limits, resolve filesystem aliases, or introduce a dependency.
Testing
The regression uses real files and a failing additional Zap core. Before the fix, both internal diagnostics landed in the backup in the single-path case; the duplicate-path case failed to rotate. Both cases now pass. From
components/internal, with Go 1.26.11:go test -mod=readonly -race -count=1 ./logger go vet -mod=readonly ./logger