fix(server): only emit ANSI log colors when stdout is a TTY#108
Merged
Conversation
The tracing fmt layer defaults ANSI on regardless of output, so under Kubernetes (piped, non-TTY stdout) the pod logs were littered with raw `\x1b[..m` escape sequences. Gate coloring on `stdout().is_terminal()` and honor `NO_COLOR` (https://no-color.org); a real terminal still gets colors for local dev. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JbrmfzHsTMMzPaSrUkZgWo
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.
Problem
watcher's own process logs contain raw ANSI escape sequences (
\x1b[2m…\x1b[0m) under Kubernetes.tracing_subscriber::fmt::layer()defaultswith_ansi(true)regardless of whether the output is a terminal, so when stdout is piped (pod logs,kubectl logs, any redirect) the color codes leak into the log text as noise.Fix
Gate ANSI on
std::io::stdout().is_terminal()and additionally honorNO_COLOR(https://no-color.org):NO_COLOR=1→ force-disabled everywhere.Testing
cargo fmt --check+cargo checkclean. This is logging-init wiring with no unit-testable seam (the behavior is a TTY check on process stdout); verified the gate compiles and theIsTerminalimport resolves. The runtime effect — no\x1b[bytes in piped output — is the whole point and shows up the next time the rolled image writes to pod logs.🤖 Generated with Claude Code