Skip to content

Conversation

@a4lg
Copy link
Contributor

@a4lg a4lg commented Nov 29, 2025

Purpose

Regular logs are not decorated with colors when non-TTY stdout/stderr is selected as logging output (c.f. _use_color function in vllm/logger.py). However, process-based decoration part in vllm/utils/system_utils.py did not implement color output suppression as the regular logger.

It resulted in excess escape sequences in a redirected output (e.g. log.txt after running vllm serve ... >log.txt 2>&1) when:

  1. The environment variable NO_COLOR is evaluated to False (i.e. either not set or equals to 0) and
  2. The output is non-TTY stdout/stderr.

This commit fixes this issue by implementing the same logic as the regular logger.

Related: #29017

Test Plan

Sorry, no new pytest test case because:

  1. The change is too simple and
  2. Testing the log seems trickier than I first initially thought.

On many Linux environment, you can manually test this behavior by running:

# 1.  TTY stdout/stderr (color decorations are acceptable)
vllm serve [OPTIONS]
# 2.  non-TTY stdout/stderr (shall not be decorated with colors)
vllm serve [OPTIONS] |& tee /dev/null

By using the tee command and a pipe (on the second invocation), both stdout/stderr (now redirected as tee's stdout) are now non-TTY and decoration with colors shall be suppressed.

Test Result

With this commit, process decorating logs like (APIServer pid=xxxx) are no longer decorated with colors on non-TTY stdout/stderr.


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

@chatgpt-codex-connector
Copy link

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

@DarkLight1337 DarkLight1337 requested a review from njhill November 29, 2025 06:48
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request aims to fix an issue where process log prefixes are colored even when output is redirected to a non-TTY device. The change correctly suppresses color for non-TTY outputs. However, it introduces an inconsistency with the main logging framework by not fully respecting the VLLM_LOGGING_COLOR environment variable. I've suggested a change to align the behavior and ensure user configuration for forcing color on or off is consistently applied.

Regular logs are not decorated with colors when non-TTY stdout/stderr is
selected as logging output (c.f. `_use_color` function in `vllm/logger.py`).

However, process-based decoration part in `vllm/utils/system_utils.py`
did not implement color output suppression as the regular logger.

It resulted in excess escape sequences in a redirected output
(e.g. `log.txt` after running `vllm serve ... >log.txt 2>&1`) when:

1.  The environment variable `NO_COLOR` is evaluated to `False` and
2.  The output is non-TTY stdout/stderr.

This commit fixes this issue by implementing the same logic
as the regular logger.

Signed-off-by: Tsukasa OI <floss_llm@irq.a4lg.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@a4lg a4lg force-pushed the system-console-log-nocolor-on-no-tty branch from e439e8d to adee1a2 Compare November 29, 2025 06:54
@ApostaC
Copy link
Collaborator

ApostaC commented Dec 1, 2025

cc @njhill

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.

2 participants