[Bugfix] Suppress non-TTY color output on the process name part of the log #29714
+6
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
Regular logs are not decorated with colors when non-TTY stdout/stderr is selected as logging output (c.f.
_use_colorfunction invllm/logger.py). However, process-based decoration part invllm/utils/system_utils.pydid not implement color output suppression as the regular logger.It resulted in excess escape sequences in a redirected output (e.g.
log.txtafter runningvllm serve ... >log.txt 2>&1) when:NO_COLORis evaluated toFalse(i.e. either not set or equals to0) andThis commit fixes this issue by implementing the same logic as the regular logger.
Related: #29017
Test Plan
Sorry, no new
pytesttest case because:On many Linux environment, you can manually test this behavior by running:
By using the
teecommand and a pipe (on the second invocation), both stdout/stderr (now redirected astee'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
supported_models.mdandexamplesfor a new model.