Skip to content

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

Merged
fitzgen merged 1 commit into
bytecodealliance:mainfrom
cfallin:fix-ansi-color-sequences
Nov 1, 2023
Merged

Wasmtime: omit ANSI color sequences in logging when not a terminal.#7436
fitzgen merged 1 commit into
bytecodealliance:mainfrom
cfallin:fix-ansi-color-sequences

Conversation

@cfallin
Copy link
Copy Markdown
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
Copy Markdown
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
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