Skip to content

Add --override-logging CLI flag to opt out of root logger reconfiguration#711

Open
wbarnha wants to merge 1 commit into
masterfrom
claude/cli-override-logging
Open

Add --override-logging CLI flag to opt out of root logger reconfiguration#711
wbarnha wants to merge 1 commit into
masterfrom
claude/cli-override-logging

Conversation

@wbarnha

@wbarnha wbarnha commented Jul 19, 2026

Copy link
Copy Markdown
Member

Description

Fixes faust-streaming/mode#36
("faust hijacks console output"). A user who configures structlog (or a plain
logging.basicConfig()) before starting a faust worker finds all output
re-prefixed with [date] [pid] [LEVEL] once the worker starts, destroying their
formatting.

Root cause: mode.utils.logging.setup_logging() unconditionally does
logging.root.handlers.clear() and reconfigures the root logger with mode's
colorlog formatter. mode.Worker already gates this behind
override_logging: bool = TrueWorker(..., override_logging=False) skips
_setup_logging() entirely. The gap is on the faust side: its CLI
(Command.worker_for_service()) built the Worker with a hardcoded kwarg list
that never passed override_logging through, and there was no CLI flag — so
anyone running the standard faust worker command couldn't reach a lever that
already existed one layer down.

This adds --override-logging/--no-override-logging, following the exact
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) -> Worker(override_logging=...)

The default is True, matching mode.Worker's own default, so existing
behavior is unchanged. No faust-streaming/mode change is needed — the
parameter already exists there.

Changes

  • faust/cli/base.py: new State.override_logging field, the
    --override-logging/--no-override-logging compat_option, the
    Command._override_logging attribute + __init__ read, the public
    override_logging property (None → True fallback), and the
    Worker(override_logging=...) pass-through.
  • tests/unit/cli/test_base.py: updated test_worker_for_service's exact
    kwarg assertion and added test_override_logging for the property.

Verification

  • pytest tests/unit/cli/test_base.py → 66 passed, 1 pre-existing skip.
  • faust ... worker --help shows the new --override-logging / --no-override-logging flag.
  • flake8 clean on both files.

Fixes faust-streaming/mode#36.

🤖 Generated with Claude Code


Generated by Claude Code

…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

codecov Bot commented Jul 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.15%. Comparing base (d95af52) to head (ef0c009).
⚠️ Report is 1 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

faust hijacks console output

1 participant