Repository navigation
feat: add ServiceLogger, and set the zerolog default context logger once - #23
Merged
Merged
Conversation
ServiceLogger returns a context whose logger carries service=name, without touching any zerolog global, so several services in one process can name themselves without racing to write DefaultContextLogger. The process-level setting moves to logging.ConfigureProcessLogging, which does what ConfigureCmdLogger does and then makes the logger the default context logger, so zerolog.Ctx works on a shutdown context made from context.Background(). InitConfig calls it in place of ConfigureCmdLogger. Fixes #20 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SS4MAwAn85D1gkEzLtjYaZ
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
cli.ServiceLogger(ctx, name)returns a context whose logger carriesservice=name, built on the logger in ctx (or the process logger). It touches no zerolog global, so several services in one process do not race overDefaultContextLogger.logging.ConfigureProcessLoggingdoes whatConfigureCmdLoggerdoes, then makes the logger zerolog's default context logger, once per process, sozerolog.Ctxworks on a shutdown context made fromcontext.Background().InitConfigcalls it in place ofConfigureCmdLogger.ExampleServiceLoggershows the field on a log line and that the globals are untouched; a concurrent test covers several services.Fixes #20
Stacked on the flags PR (this base branch).
🤖 Generated with Claude Code
https://claude.ai/code/session_01SS4MAwAn85D1gkEzLtjYaZ