refactor(logger): bind repeated log context with child loggers#2769
Draft
goastler wants to merge 1 commit into
Draft
refactor(logger): bind repeated log context with child loggers#2769goastler wants to merge 1 commit into
goastler wants to merge 1 commit into
Conversation
Use Logger.with to bind context once rather than repeating the same data block in every log call across mongo, redis-client, env startup cleanup, and provider IP validation.
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.
What
Replace places where a logger was passed/held and the same contextual metadata was re-attached on every individual log call with a single child logger created via
Logger.with(...), which binds that context once.Changes
database—base/mongo.ts: bindmongoUrlonce in the constructor (was repeated across ~11connect()/close()log calls).redis-client—redisClient.ts: bindurlinconnectToRedisandnameinsetupRedisIndexonce each.env—provider.ts: bindfailedFuncNameonce incleanup()(was duplicated across two error handlers).provider—util.ts: bindchallengeIp/providedIponce at the top ofdeepValidateIpAddress(was repeated across ~7 log calls).No behavioural change — the same fields are emitted, just bound once instead of inline. Type-checked (
build:tsc) for all four packages.