Skip to content

Isolate LogSyslogDriver from the root logger (#2102) - #259

Closed
tmgbedu wants to merge 1 commit into
mainfrom
task/syslog-driver-root-handler
Closed

tmgbedu wants to merge 1 commit into
mainfrom
task/syslog-driver-root-handler

Conversation

@tmgbedu

@tmgbedu tmgbedu commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Root cause

LogSyslogDriver.__init__ used logging.getLogger("root") (the actual root logger), added a fresh SysLogHandler on every construction and mutated the root level. Handlers piled up, and since the LoggingHandler bridge also sits on root, syslog-driver records were fed back into Logger (possible loop).

Fix

Mirrors the PR #257 pattern (independent of it, branched off main):

  • Dedicated logger fastapi_startkit.logging.syslog.<address> with propagate = False
  • One SysLogHandler per address, reused across constructions
  • New close() to detach and close the handler
  • Level methods unchanged, so existing tests stay green

Tests

New tests/logging/test_syslog_driver.py (SysLogHandler mocked, no real socket):

  • 25 constructions leave root handlers/level unchanged
  • Repeated construction reuses one handler (SysLogHandler built once)
  • Distinct addresses get distinct handlers
  • Records reach the syslog handler and never hit the LoggingHandler bridge
  • close() detaches and closes the handler

These fail on current main and pass with the fix. Full suite: 2487 passed; LogSyslogDriver.py 100% coverage; ruff clean; basedpyright 0.

🤖 Generated with Claude Code

Each construction attached a new SysLogHandler to the root logger and
changed its level; records then also hit the LoggingHandler bridge on
root and looped back into Logger. Use a dedicated non-propagating logger
per address with one reused handler, and add close().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Sep 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@tmgbedu tmgbedu closed this Sep 27, 2026
@tmgbedu
tmgbedu deleted the task/syslog-driver-root-handler branch September 27, 2026 19:13
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.

1 participant