Send Airflow CLI logs to stderr for -o commands so structured output stays parseable#68598
Open
dheerajturaga wants to merge 1 commit into
Open
Conversation
…stays parseable CLI commands that accept -o (table|json|yaml|plain) write structured data to stdout. Airflow's default logging config routes the root console handler to sys.stdout, so any log line emitted while such a command runs is mixed into that data and breaks downstream parsers (most visibly: the Celery default visibility_timeout warning corrupts `airflow celery list-workers -o json` output). After parse_args() in the CLI entrypoint, redirect any root-logger StreamHandler whose stream is sys.stdout to sys.stderr, gated on hasattr(args, 'output'). Daemon commands (scheduler, api-server, celery worker, ...) do not register -o and so keep their existing stdout-logging behavior.
84dc03b to
89f3c62
Compare
Contributor
|
Moving to 3.3.1 as planning to only include critical/high priority bug fixes to 3.3.0 found in 3.3.0b2 testing. |
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.
CLI commands that accept -o (table|json|yaml|plain) write structured data to stdout. Airflow's default logging config routes the root console handler to sys.stdout, so any log line emitted while such a command runs is mixed into that data and breaks downstream parsers (most visibly: the Celery default visibility_timeout warning corrupts
airflow celery list-workers -o jsonoutput).After parse_args() in the CLI entrypoint, redirect any root-logger StreamHandler whose stream is sys.stdout to sys.stderr, gated on hasattr(args, 'output'). Daemon commands (scheduler, api-server, celery worker, ...) do not register -o and so keep their existing stdout-logging behavior.
Was generative AI tooling used to co-author this PR?
Claude Code Opus 4.7