GitHub
07/04/2026, 9:22 AMFORCE_COLOR when deciding whether to emit colored log output.
The change keeps the existing precedence:
• NO_COLOR still disables colors.
• TTY detection still controls colors by default.
• FORCE_COLOR enables colored logging when stderr is not a TTY.
• Non-colored log formats remain unchanged.
Details
The colored logging path now enables colors when either stderr is attached to a TTY or FORCE_COLOR is truthy:
colors = (
sys.stderr.isatty() or get_boolean_env_var("FORCE_COLOR")
) and not get_no_color_flag()
This preserves NO_COLOR precedence because the final condition still requires not get_no_color_flag().
The existing colored-non-tty-force-color test case already described the intended behavior and was marked xfail because FORCE_COLOR was not honored. This PR implements that behavior and removes the xfail.
Tests
uv run pytest tests/meltano/core/logging/test_logging_utils.py::test_default_logging_config_format
uv run pytest \
tests/meltano/core/logging/test_logging_utils.py \
tests/meltano/core/logging/test_formatters.py \
tests/meltano/core/logging/test_renderers.py \
tests/meltano/cli/test_cli.py::TestCliColors \
tests/meltano/cli/test_run.py:TestCliRunScratchpadOne:test_color_console_exception_handler
uv run --with ruff ruff check src/meltano/core/logging/utils.py tests/meltano/core/logging/test_logging_utils.py
uv run --with ruff ruff format --check src/meltano/core/logging/utils.py tests/meltano/core/logging/test_logging_utils.py
GIT_PAGER=cat git diff --check
Results:
• `test_default_logging_config_format`: 7 passed
• Wider relevant logging/CLI test set: 61 passed
• Ruff check passed
• Ruff format check passed
• git diff --check passed
Summary by Sourcery
Honor the FORCE_COLOR environment variable in default logging configuration so colored logs can be enabled even when stderr is not a TTY, while preserving NO_COLOR precedence.
Bug Fixes:
• Ensure colored logging is correctly enabled when FORCE_COLOR is set in non-TTY environments.
Tests:
• Update logging configuration tests to reflect FORCE_COLOR behavior and remove the previous expected failure for the colored non-tty FORCE_COLOR case.
meltano/meltanoGitHub
07/19/2026, 3:40 AM