mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-11 04:34:54 +08:00
Make vLLM logging formatting optional (#2877)
This commit is contained in:
parent
63e2a6419d
commit
181b27d881
@ -5,6 +5,8 @@ import logging
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
VLLM_CONFIGURE_LOGGING = int(os.getenv("VLLM_CONFIGURE_LOGGING", "1"))
|
||||||
|
|
||||||
_FORMAT = "%(levelname)s %(asctime)s %(filename)s:%(lineno)d] %(message)s"
|
_FORMAT = "%(levelname)s %(asctime)s %(filename)s:%(lineno)d] %(message)s"
|
||||||
_DATE_FORMAT = "%m-%d %H:%M:%S"
|
_DATE_FORMAT = "%m-%d %H:%M:%S"
|
||||||
|
|
||||||
@ -45,13 +47,15 @@ def _setup_logger():
|
|||||||
# The logger is initialized when the module is imported.
|
# The logger is initialized when the module is imported.
|
||||||
# This is thread-safe as the module is only imported once,
|
# This is thread-safe as the module is only imported once,
|
||||||
# guaranteed by the Python GIL.
|
# guaranteed by the Python GIL.
|
||||||
_setup_logger()
|
if VLLM_CONFIGURE_LOGGING:
|
||||||
|
_setup_logger()
|
||||||
|
|
||||||
|
|
||||||
def init_logger(name: str):
|
def init_logger(name: str):
|
||||||
# Use the same settings as above for root logger
|
# Use the same settings as above for root logger
|
||||||
logger = logging.getLogger(name)
|
logger = logging.getLogger(name)
|
||||||
logger.setLevel(os.getenv("LOG_LEVEL", "DEBUG"))
|
logger.setLevel(os.getenv("LOG_LEVEL", "DEBUG"))
|
||||||
|
if VLLM_CONFIGURE_LOGGING:
|
||||||
logger.addHandler(_default_handler)
|
logger.addHandler(_default_handler)
|
||||||
logger.propagate = False
|
logger.propagate = False
|
||||||
return logger
|
return logger
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user