Skip to content

Commit e439e8d

Browse files
committed
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 on 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>
1 parent 4a80ad0 commit e439e8d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

vllm/utils/system_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ 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+
if envs.NO_COLOR or not hasattr(file, "isatty") or not file.isatty():
179179
prefix = f"({worker_name} pid={pid}) "
180180
else:
181181
prefix = f"{CYAN}({worker_name} pid={pid}){RESET} "

0 commit comments

Comments
 (0)