Signed-off-by: <> Co-authored-by: William Lin <SolitaryThinker@users.noreply.github.com> Co-authored-by: Will Lin <wlsaidhi@gmail.com> Co-authored-by: Zhou, Wei <wzhou322@gatech.edu> Co-authored-by: Kevin Lin <42618777+kevin314@users.noreply.github.com> Co-authored-by: kevin314 <kevin.lin.cs1@gmail.com> Co-authored-by: JerryZhou54 <69577934+JerryZhou54@users.noreply.github.com> Co-authored-by: Yongqi Chen <144848849+BrianChen1129@users.noreply.github.com> Co-authored-by: Peiyuan Zhang <m2deng@ucsd.edu>
19 lines
627 B
Python
19 lines
627 B
Python
# SPDX-License-Identifier: Apache-2.0
|
|
# adapted from vllm: https://github.com/vllm-project/vllm/blob/v0.7.3/vllm/logging_utils/formatter.py
|
|
|
|
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
|