mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2026-07-20 16:27:19 +08:00
Merge 13cb3e44373beb1c8b9d2c017f565af6f7a1b601 into 254f6b986720c92ddf97fbb1a6a6465da8e87e29
This commit is contained in:
commit
41567c2495
@ -40,6 +40,7 @@ if TYPE_CHECKING:
|
|||||||
VLLM_USAGE_SOURCE: str = ""
|
VLLM_USAGE_SOURCE: str = ""
|
||||||
VLLM_CONFIGURE_LOGGING: bool = True
|
VLLM_CONFIGURE_LOGGING: bool = True
|
||||||
VLLM_LOGGING_LEVEL: str = "INFO"
|
VLLM_LOGGING_LEVEL: str = "INFO"
|
||||||
|
VLLM_LOGGING_IMPORT_PACKAGE_FILE: bool = False
|
||||||
VLLM_LOGGING_PREFIX: str = ""
|
VLLM_LOGGING_PREFIX: str = ""
|
||||||
VLLM_LOGGING_STREAM: str = "ext://sys.stdout"
|
VLLM_LOGGING_STREAM: str = "ext://sys.stdout"
|
||||||
VLLM_LOGGING_CONFIG_PATH: str | None = None
|
VLLM_LOGGING_CONFIG_PATH: str | None = None
|
||||||
@ -647,6 +648,12 @@ environment_variables: dict[str, Callable[[], Any]] = {
|
|||||||
"VLLM_LOGGING_CONFIG_PATH": lambda: os.getenv("VLLM_LOGGING_CONFIG_PATH"),
|
"VLLM_LOGGING_CONFIG_PATH": lambda: os.getenv("VLLM_LOGGING_CONFIG_PATH"),
|
||||||
# this is used for configuring the default logging level
|
# this is used for configuring the default logging level
|
||||||
"VLLM_LOGGING_LEVEL": lambda: os.getenv("VLLM_LOGGING_LEVEL", "INFO").upper(),
|
"VLLM_LOGGING_LEVEL": lambda: os.getenv("VLLM_LOGGING_LEVEL", "INFO").upper(),
|
||||||
|
# If set to 0, vllm will only print file name in logging record
|
||||||
|
# If set to 1, vllm will print import package file name in logging record
|
||||||
|
"VLLM_LOGGING_IMPORT_PACKAGE_FILE": lambda: os.environ.get(
|
||||||
|
"VLLM_LOGGING_IMPORT_PACKAGE_FILE", "0"
|
||||||
|
)
|
||||||
|
== "1",
|
||||||
# this is used for configuring the default logging stream
|
# this is used for configuring the default logging stream
|
||||||
"VLLM_LOGGING_STREAM": lambda: os.getenv("VLLM_LOGGING_STREAM", "ext://sys.stdout"),
|
"VLLM_LOGGING_STREAM": lambda: os.getenv("VLLM_LOGGING_STREAM", "ext://sys.stdout"),
|
||||||
# if set, VLLM_LOGGING_PREFIX will be prepended to all log messages
|
# if set, VLLM_LOGGING_PREFIX will be prepended to all log messages
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
import os
|
||||||
|
|
||||||
from vllm import envs
|
from vllm import envs
|
||||||
|
|
||||||
@ -13,62 +13,18 @@ class NewLineFormatter(logging.Formatter):
|
|||||||
def __init__(self, fmt, datefmt=None, style="%"):
|
def __init__(self, fmt, datefmt=None, style="%"):
|
||||||
super().__init__(fmt, datefmt, style)
|
super().__init__(fmt, datefmt, style)
|
||||||
|
|
||||||
self.use_relpath = envs.VLLM_LOGGING_LEVEL == "DEBUG"
|
|
||||||
if self.use_relpath:
|
|
||||||
self.root_dir = Path(__file__).resolve().parent.parent.parent
|
|
||||||
|
|
||||||
def format(self, record):
|
def format(self, record):
|
||||||
def shrink_path(relpath: Path) -> str:
|
filename = getattr(record, "filename", None)
|
||||||
"""
|
assert filename is not None
|
||||||
Shortens a file path for logging display:
|
name = getattr(record, "name", None)
|
||||||
- Removes leading 'vllm' folder if present.
|
|
||||||
- If path starts with 'v1',
|
|
||||||
keeps the first two and last two levels,
|
|
||||||
collapsing the middle as '...'.
|
|
||||||
- Otherwise, keeps the first and last two levels,
|
|
||||||
collapsing the middle as '...'.
|
|
||||||
- If the path is short, returns it as-is.
|
|
||||||
- Examples:
|
|
||||||
vllm/model_executor/layers/quantization/utils/fp8_utils.py ->
|
|
||||||
model_executor/.../quantization/utils/fp8_utils.py
|
|
||||||
vllm/model_executor/layers/quantization/awq.py ->
|
|
||||||
model_executor/layers/quantization/awq.py
|
|
||||||
vllm/v1/attention/backends/mla/common.py ->
|
|
||||||
v1/attention/backends/mla/common.py
|
|
||||||
|
|
||||||
Args:
|
record.fileinfo = filename
|
||||||
relpath (Path): The relative path to be shortened.
|
if envs.VLLM_LOGGING_IMPORT_PACKAGE_FILE and name is not None:
|
||||||
Returns:
|
# assume logger name is the package name, ie, __name__
|
||||||
str: The shortened path string for display.
|
parts = name.split(".")
|
||||||
"""
|
if filename != "__init__.py":
|
||||||
parts = list(relpath.parts)
|
parts = parts[:-1]
|
||||||
new_parts = []
|
record.fileinfo = os.path.join(*parts, filename)
|
||||||
if parts and parts[0] == "vllm":
|
|
||||||
parts = parts[1:]
|
|
||||||
if parts and parts[0] == "v1":
|
|
||||||
new_parts += parts[:2]
|
|
||||||
parts = parts[2:]
|
|
||||||
elif parts:
|
|
||||||
new_parts += parts[:1]
|
|
||||||
parts = parts[1:]
|
|
||||||
if len(parts) > 2:
|
|
||||||
new_parts += ["..."] + parts[-2:]
|
|
||||||
else:
|
|
||||||
new_parts += parts
|
|
||||||
return "/".join(new_parts)
|
|
||||||
|
|
||||||
if self.use_relpath:
|
|
||||||
abs_path = getattr(record, "pathname", None)
|
|
||||||
if abs_path:
|
|
||||||
try:
|
|
||||||
relpath = Path(abs_path).resolve().relative_to(self.root_dir)
|
|
||||||
except Exception:
|
|
||||||
relpath = Path(record.filename)
|
|
||||||
else:
|
|
||||||
relpath = Path(record.filename)
|
|
||||||
record.fileinfo = shrink_path(relpath)
|
|
||||||
else:
|
|
||||||
record.fileinfo = record.filename
|
|
||||||
|
|
||||||
msg = super().format(record)
|
msg = super().format(record)
|
||||||
if record.message != "":
|
if record.message != "":
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user