Repository navigation
fix(logging): colour default log lines only on a terminal - #186
Merged
Merged
Conversation
aroff
enabled auto-merge (squash)
October 17, 2026 11:21
aroff
disabled auto-merge
October 17, 2026 11:22
init_default_logging wrote ANSI escape codes whatever stdout was, so a service in a container sent them verbatim to kubectl logs and the log store. It now follows the crate's stdout colour rule: NO_COLOR > FORCE_COLOR > terminal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aroff
force-pushed
the
fix/default-logging-ansi-off-terminal
branch
from
October 17, 2026 19:00
5d40c29 to
8728336
Compare
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.
What
init_default_logging()built its fmt layer with the defaultansi = true, so every line carried ANSI escape codes even when stdout is a pipe or a container log. In Kubernetes those codes land verbatim inkubectl logsand in Loki.The default subscriber now calls
with_ansi(cli_mode::should_color_output()), the crate's existing stdout colour rule:NO_COLOR>FORCE_COLOR> terminal. Both bodies ofinstall_default_logging(with and withouttelemetry) use it.Found while wiring logging into Pauta's
serve(rudaia-hq/pauta spec 011), whose pod logs go to Loki.Tests
tests/unit/default_logging_color.rs(unit_default_logging_color, featureobservability). Installing the subscriber is a one-way, process-global step, so each case re-runs the test binary with stdout piped:a_pipe_gets_plain_lines: no\x1bin the output. Fails onmain(checked by reverting the fix).force_color_colours_a_pipe:FORCE_COLOR=1gives escape codes, so the check above means something.no_color_wins_over_force_color.Runs under
--features observabilityand--features telemetry. The existingunit_telemetry_logging_guard,unit_telemetry_slot_forwardingandunit_telemetry_startup_logging_upgradestill pass.cargo fmt --checkandcargo clippy --all-features -- -D warningsare clean.What could leak
Nothing new. This changes only the formatting of lines that were already written.
🤖 Generated with Claude Code