vllm.logging_utils ¶
Modules:
| Name | Description |
|---|---|
access_log_filter | Access log filter for uvicorn to exclude specific endpoints from logging. |
dump_input | |
formatter | |
lazy | |
log_time | Provides a timeslice logging decorator |
__all__ module-attribute ¶
__all__ = [
"NewLineFormatter",
"ColoredFormatter",
"UvicornAccessLogFilter",
"create_uvicorn_log_config",
"lazy",
"logtime",
]
ColoredFormatter ¶
Bases: NewLineFormatter
Adds ANSI color codes to log levels for terminal output.
This formatter adds colors by injecting them into the format string for static elements (timestamp, filename, line number) and modifying the levelname attribute for dynamic color selection.
Source code in vllm/logging_utils/formatter.py
COLORS class-attribute instance-attribute ¶
COLORS = {
"DEBUG": "\x1b[37m",
"INFO": "\x1b[32m",
"WARNING": "\x1b[33m",
"ERROR": "\x1b[31m",
"CRITICAL": "\x1b[35m",
}
__init__ ¶
Source code in vllm/logging_utils/formatter.py
format ¶
Source code in vllm/logging_utils/formatter.py
NewLineFormatter ¶
Bases: Formatter
Adds logging prefix to newlines to align multi-line messages.
Source code in vllm/logging_utils/formatter.py
__init__ ¶
format ¶
Source code in vllm/logging_utils/formatter.py
UvicornAccessLogFilter ¶
Bases: Filter
A logging filter that excludes access logs for specified endpoint paths.
This filter is designed to work with uvicorn's access logger. It checks the log record's arguments for the request path and filters out records matching the excluded paths.
Uvicorn access log format
'%s - "%s %s HTTP/%s" %d' (client_addr, method, path, http_version, status_code)
Example
127.0.0.1:12345 - "GET /health HTTP/1.1" 200
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
excluded_paths | list[str] | None | A list of URL paths to exclude from logging. Paths are matched exactly. Example: ["/health", "/metrics"] | None |
Source code in vllm/logging_utils/access_log_filter.py
__init__ ¶
filter ¶
Determine if the log record should be logged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record | LogRecord | The log record to evaluate. | required |
Returns:
| Type | Description |
|---|---|
bool | True if the record should be logged, False otherwise. |
Source code in vllm/logging_utils/access_log_filter.py
create_uvicorn_log_config ¶
create_uvicorn_log_config(
excluded_paths: list[str] | None = None,
log_level: str = "info",
) -> dict
Create a uvicorn logging configuration with access log filtering.
This function generates a logging configuration dictionary that can be passed to uvicorn's log_config parameter. It sets up the access log filter to exclude specified paths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
excluded_paths | list[str] | None | List of URL paths to exclude from access logs. | None |
log_level | str | The log level for uvicorn loggers. | 'info' |
Returns:
| Type | Description |
|---|---|
dict | A dictionary containing the logging configuration. |
Example
config = create_uvicorn_log_config(["/health", "/metrics"]) uvicorn.run(app, log_config=config)
Source code in vllm/logging_utils/access_log_filter.py
logtime ¶
Logs the execution time of the decorated function. Always place it beneath other decorators.