Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wasmtime: omit ANSI color sequences in logging when not a terminal. #7436

Merged
merged 1 commit into from
Nov 1, 2023

Conversation

cfallin
Copy link
Member

@cfallin cfallin commented Nov 1, 2023

In #7239 we added a tracing-log subscriber that prints logs to stderr if enabled with an environment variable. It included logic to add ANSI color sequences when stderr is a terminal, for legibility. Unfortunately it seems that while this logic enabled colors on a terminal, it did not disable colors on a non-terminal; so redirects of stderr to a file would result in ANSI color sequences being captured in that file. Specifically, the builder seems not to default to no-color; so rather than enable-or-nothing, we should explicitly enable or disable always.

Fixes #7435.

In bytecodealliance#7239 we added a `tracing-log` subscriber that prints logs to stderr
if enabled with an environment variable. It included logic to add ANSI
color sequences when stderr is a terminal, for legibility. Unfortunately
it seems that while this logic *enabled* colors on a terminal, it did
not *disable* colors on a non-terminal; so redirects of stderr to a file
would result in ANSI color sequences being captured in that file.
Specifically, the builder seems not to default to no-color; so rather
than enable-or-nothing, we should explicitly enable or disable always.

Fixes bytecodealliance#7435.
@cfallin cfallin requested a review from a team as a code owner November 1, 2023 05:04
@cfallin cfallin requested review from pchickey and removed request for a team November 1, 2023 05:04
@alexcrichton alexcrichton added this pull request to the merge queue Nov 1, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 1, 2023
@fitzgen fitzgen added this pull request to the merge queue Nov 1, 2023
@pchickey
Copy link
Contributor

pchickey commented Nov 1, 2023

Thanks, I should have tested for this case instead of assuming it would be fine.

Merged via the queue into bytecodealliance:main with commit dcc8c2b Nov 1, 2023
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WASMTIME_LOG output emits ANSI sequences when redirecting stderr to file
4 participants