Skip to content

feat: add ServiceLogger, and set the zerolog default context logger once - #23

Merged
patdowney merged 1 commit into
fix/flags-follow-config-keysfrom
feat/service-logger
Nov 14, 2026
Merged

patdowney merged 1 commit into
fix/flags-follow-config-keysfrom
feat/service-logger

Conversation

@patdowney

Copy link
Copy Markdown
Contributor

Summary

  • cli.ServiceLogger(ctx, name) returns a context whose logger carries service=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 over DefaultContextLogger.
  • logging.ConfigureProcessLogging does what ConfigureCmdLogger does, then makes the logger zerolog's default context logger, once per process, so zerolog.Ctx works on a shutdown context made from context.Background(). InitConfig calls it in place of ConfigureCmdLogger.
  • ExampleServiceLogger shows 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

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
@patdowney
patdowney added this pull request to stack #25 November 14, 2026 23:37
@patdowney
patdowney merged commit fab8c05 into master Nov 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ServiceLogger, and set zerolog globals once per process

1 participant