Repository navigation
fix(logging): only color console logs on a terminal - #5616
Merged
Merged
Conversation
tracing-subscriber's formatter enables ANSI unless NO_COLOR is set and does no terminal detection, so the gateway, compute drivers, credential drivers, and certgen wrote escape codes into container logs collected by GKE and other log pipelines. Move the CLI's automatic color rules (NO_COLOR, FORCE_COLOR, terminal plus TERM capability) into openshell_core::color and pass the result to with_ansi in every long-running binary's console layer. The CLI keeps --color always|never and delegates its auto branch to the shared helper. Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com>
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
🌿 Preview your docs: https://nvidia-preview-pr-5616.docs.buildwithfern.com/openshell |
pimlock
marked this pull request as ready for review
November 16, 2026 20:07
TaylorMutch
approved these changes
Nov 16, 2026
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.
Summary
Right now our gateway logs in the GKE look like this:
This PR fixes that and makes the ANSI color usage consistent across all the spots.
The approach follows what other projects do:
NO_COLORis set -> output plain textFORCE_COLORis set -> output ANSI color escapesRelated Issue
No issue required: localized bug fix with the full context in this PR.
Changes
openshell_core::colorwithstdout_ansi()andstderr_ansi().NO_COLORdisables color,FORCE_COLORforces it, and otherwise the stream must be a terminal whoseTERMrenders ANSI. These are the same rules the CLI already used.with_ansi.openshell_otel::DriverTracingConfiggains anansifield, becauseopenshell-oteldoes not depend onopenshell-core. The Docker, Podman, Kubernetes, and VM driver binaries set it.--color always|neverand delegates itsautobranch to the shared helper, so the duplicatedTERMand env-var rules are removed.docs/observability/accessing-logs.mdx.Machine-readable JSON console logs (with a GCP-compatible
severityfield) would be a separate follow-up.Testing
mise run pre-commitpassesopenshell-corewith their tests; the CLIresolvetests still pass)Manual check: ran
openshell-gatewaywith output redirected to a file. All 10 log lines were plain. WithFORCE_COLOR=1, all 10 were colored. This has not been checked on GKE.Checklist