[Fix] Support passing args to logger (#17425)

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
Aaron Pham
2025-04-30 11:06:58 -04:00
committed by GitHub
parent 39317cf42b
commit da4e7687b5
13 changed files with 75 additions and 79 deletions

View File

@@ -5,6 +5,7 @@ import json
import logging
import os
import sys
from collections.abc import Hashable
from functools import lru_cache, partial
from logging import Logger
from logging.config import dictConfig
@@ -52,15 +53,15 @@ DEFAULT_LOGGING_CONFIG = {
@lru_cache
def _print_info_once(logger: Logger, msg: str) -> None:
def _print_info_once(logger: Logger, msg: str, *args: Hashable) -> None:
# Set the stacklevel to 2 to print the original caller's line info
logger.info(msg, stacklevel=2)
logger.info(msg, *args, stacklevel=2)
@lru_cache
def _print_warning_once(logger: Logger, msg: str) -> None:
def _print_warning_once(logger: Logger, msg: str, *args: Hashable) -> None:
# Set the stacklevel to 2 to print the original caller's line info
logger.warning(msg, stacklevel=2)
logger.warning(msg, *args, stacklevel=2)
class _VllmLogger(Logger):
@@ -72,19 +73,19 @@ class _VllmLogger(Logger):
`intel_extension_for_pytorch.utils._logger`.
"""
def info_once(self, msg: str) -> None:
def info_once(self, msg: str, *args: Hashable) -> None:
"""
As :meth:`info`, but subsequent calls with the same message
are silently dropped.
"""
_print_info_once(self, msg)
_print_info_once(self, msg, *args)
def warning_once(self, msg: str) -> None:
def warning_once(self, msg: str, *args: Hashable) -> None:
"""
As :meth:`warning`, but subsequent calls with the same message
are silently dropped.
"""
_print_warning_once(self, msg)
_print_warning_once(self, msg, *args)
def _configure_vllm_root_logger() -> None: