Skip to content

Commit adee1a2

Browse files
Suppress non-TTY color output on the process name part of the log
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>
1 parent 4a80ad0 commit adee1a2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

vllm/utils/system_utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,12 @@ def set_process_title(
175175

176176
def _add_prefix(file: TextIO, worker_name: str, pid: int) -> None:
177177
"""Add colored prefix to file output for log decoration."""
178-
if envs.NO_COLOR:
178+
is_tty = hasattr(file, "isatty") and file.isatty()
179+
if (
180+
envs.NO_COLOR
181+
or envs.VLLM_LOGGING_COLOR == "0"
182+
or (envs.VLLM_LOGGING_COLOR != "1" and not is_tty)
183+
):
179184
prefix = f"({worker_name} pid={pid}) "
180185
else:
181186
prefix = f"{CYAN}({worker_name} pid={pid}){RESET} "

0 commit comments

Comments
 (0)