Make vLLM logging formatting optional (#2877)

This commit is contained in:
Antoni Baum 2024-02-20 14:38:55 -08:00 committed by GitHub
parent 63e2a6419d
commit 181b27d881
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,6 +5,8 @@ import logging
import sys
import os
VLLM_CONFIGURE_LOGGING = int(os.getenv("VLLM_CONFIGURE_LOGGING", "1"))
_FORMAT = "%(levelname)s %(asctime)s %(filename)s:%(lineno)d] %(message)s"
_DATE_FORMAT = "%m-%d %H:%M:%S"
@ -45,13 +47,15 @@ def _setup_logger():
# The logger is initialized when the module is imported.
# This is thread-safe as the module is only imported once,
# guaranteed by the Python GIL.
_setup_logger()
if VLLM_CONFIGURE_LOGGING:
_setup_logger()
def init_logger(name: str):
# Use the same settings as above for root logger
logger = logging.getLogger(name)
logger.setLevel(os.getenv("LOG_LEVEL", "DEBUG"))
logger.addHandler(_default_handler)
logger.propagate = False
if VLLM_CONFIGURE_LOGGING:
logger.addHandler(_default_handler)
logger.propagate = False
return logger