[pull] main from livekit:main - #481
Merged
Merged
Conversation
* logger/zaputil: replay deferred writes through Check Deferrer.write and Deferrer.flush called the wrapped core's Write directly, bypassing Check. zapcore.multiCore.Write fans out to every child unconditionally, so a destination that filters in Check rather than in Write received entries it never enabled. encoderCore was immune because it re-checks each out's level inside Write; nothing else is, including zaptest/observer. testCore now registers itself in Check. It overrides Write but not Check, so its Write only ever ran because the deferred path skipped Check. * logger: replace WithTap with WithTee WithTap took a WriteSyncer, so a tap could only ever receive bytes encoded by a zaputil-chosen encoder: Encoder.Core took two destinations and DevelopmentEncoder carried a second JSON encoder that existed only to format tap output. WithTee hands the duplicate stream a zapcore.Core instead, which brings its own encoder and sees the structured entry. A Tee builds its core from the derived logger's resolved enabler, so it shares the console's level rather than widening what the logger emits, and the component leveler no longer has to OR a tap's level in. Fields do not arrive on their own: WithValues bakes them into the encoder and replaces the whole core, and the sugared path never calls Core.With, so a Tee accumulates them itself. Benchmarks cover objects allocated per WithValues and WithDeferredValues, with and without a tee. * logger/zaputil: replace encoderCore with zapcore.NewCore With one destination per core, encoderCore is zapcore.ioCore plus a per-destination level re-check on write, and that check became redundant once the deferred path started replaying through Check. * logger/zaputil: drop the Encoder type parameter Encoder was generic because WithValues returned a concrete type, and there were two concrete types because DevelopmentEncoder needed a second encoder for the tap. Both are now one encoder and one destination, so the interface and its two implementations collapse into a struct with two constructors, and zapLogger, newZapLogger and zapLoggerComponentLeveler stop being generic. * logger: make the component leveler replaceable per branch Component levels resolved through one process-global sharedConfig, so the only per-tenant knob was WithMinLevel: a flat floor that also bypassed the write-enabler cache and allocated a WriteEnabler on every derivation. zaputil.ComponentLeveler now owns both the per-component level and the write-enabler cache, and WithComponentLeveler attaches one to a branch of the logger tree. A derived leveler can only widen its parent, which is what lets a global config change reach every branch without the root holding references to its children. Replaces WithMinLevel. * changeset: cover WithComponentLeveler * logger: tighten the tee comments
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )