[Misc] Colorize logs (#29017)

Signed-off-by: Nick Hill <nhill@redhat.com>
This commit is contained in:
Nick Hill
2025-11-19 19:26:04 -05:00
committed by GitHub
parent 537cc635c7
commit 9ccef8e333
6 changed files with 152 additions and 62 deletions
+5 -2
View File
@@ -22,7 +22,7 @@ from .platform_utils import cuda_is_initialized, xpu_is_initialized
logger = init_logger(__name__)
CYAN = "\033[1;36m"
CYAN = "\033[0;36m"
RESET = "\033[0;0m"
@@ -142,7 +142,10 @@ def set_process_title(
def _add_prefix(file: TextIO, worker_name: str, pid: int) -> None:
"""Add colored prefix to file output for log decoration."""
prefix = f"{CYAN}({worker_name} pid={pid}){RESET} "
if envs.NO_COLOR:
prefix = f"({worker_name} pid={pid}) "
else:
prefix = f"{CYAN}({worker_name} pid={pid}){RESET} "
file_write = file.write
def write_with_prefix(s: str):