[MISC] Rework logger to enable pythonic custom logging configuration to be provided (#4273)

This commit is contained in:
Danny Guinther
2024-05-01 17:34:40 -07:00
committed by GitHub
parent 826b82a260
commit b8afa8b95a
5 changed files with 456 additions and 53 deletions
+5
View File
@@ -0,0 +1,5 @@
from vllm.logging.formatter import NewLineFormatter
__all__ = [
"NewLineFormatter",
]
+15
View File
@@ -0,0 +1,15 @@
import logging
class NewLineFormatter(logging.Formatter):
"""Adds logging prefix to newlines to align multi-line messages."""
def __init__(self, fmt, datefmt=None, style="%"):
logging.Formatter.__init__(self, fmt, datefmt, style)
def format(self, record):
msg = logging.Formatter.format(self, record)
if record.message != "":
parts = msg.split(record.message)
msg = msg.replace("\n", "\r\n" + parts[0])
return msg