Add --override-logging CLI flag to opt out of root logger reconfiguration#711
Open
wbarnha wants to merge 1 commit into
Open
Add --override-logging CLI flag to opt out of root logger reconfiguration#711wbarnha wants to merge 1 commit into
wbarnha wants to merge 1 commit into
Conversation
…tion mode.Worker already supports override_logging=False to skip setup_logging()'s logging.root.handlers.clear() + colorlog reconfiguration, letting a caller's own logging setup (e.g. structlog piped into stdlib logging, or a plain logging.basicConfig()) survive worker startup. But faust's CLI (Command.worker_for_service()) constructed the Worker with a hardcoded kwarg list that never passed override_logging through, and there was no CLI flag for it -- so anyone running the standard `faust worker` command had no way to reach a lever that already existed one layer down. Add --override-logging/--no-override-logging, following the same compat_option pattern already used for --loglevel/--blocking-timeout/ --console-port: CLI flag -> State.override_logging -> Command ._override_logging -> Command.override_logging property (default True, matching mode.Worker's own default) -> Worker(override_logging=...). Fixes faust-streaming/mode#36. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HHPL4VFWQRQPpjR1gXSKyL
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #711 +/- ##
=======================================
Coverage 94.15% 94.15%
=======================================
Files 104 104
Lines 11136 11145 +9
Branches 1201 1201
=======================================
+ Hits 10485 10494 +9
Misses 550 550
Partials 101 101 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Description
Fixes faust-streaming/mode#36
("faust hijacks console output"). A user who configures
structlog(or a plainlogging.basicConfig()) before starting a faust worker finds all outputre-prefixed with
[date] [pid] [LEVEL]once the worker starts, destroying theirformatting.
Root cause:
mode.utils.logging.setup_logging()unconditionally doeslogging.root.handlers.clear()and reconfigures the root logger with mode'scolorlog formatter.
mode.Workeralready gates this behindoverride_logging: bool = True—Worker(..., override_logging=False)skips_setup_logging()entirely. The gap is on the faust side: its CLI(
Command.worker_for_service()) built theWorkerwith a hardcoded kwarg listthat never passed
override_loggingthrough, and there was no CLI flag — soanyone running the standard
faust workercommand couldn't reach a lever thatalready existed one layer down.
This adds
--override-logging/--no-override-logging, following the exactcompat_optionpattern already used for--loglevel/--blocking-timeout/--console-port:The default is
True, matchingmode.Worker's own default, so existingbehavior is unchanged. No
faust-streaming/modechange is needed — theparameter already exists there.
Changes
faust/cli/base.py: newState.override_loggingfield, the--override-logging/--no-override-loggingcompat_option, theCommand._override_loggingattribute +__init__read, the publicoverride_loggingproperty (None →Truefallback), and theWorker(override_logging=...)pass-through.tests/unit/cli/test_base.py: updatedtest_worker_for_service's exactkwarg assertion and added
test_override_loggingfor the property.Verification
pytest tests/unit/cli/test_base.py→ 66 passed, 1 pre-existing skip.faust ... worker --helpshows the new--override-logging / --no-override-loggingflag.Fixes faust-streaming/mode#36.
🤖 Generated with Claude Code
Generated by Claude Code