-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce VLLM_VERBOSITY
environment variable
#1165
Changes from 3 commits
629785c
10da197
b866fe8
e951985
515886e
444fc5c
5c196d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,24 @@ | ||
# Adapted from | ||
# https://github.com/skypilot-org/skypilot/blob/86dc0f6283a335e4aa37b3c10716f90999f48ab6/sky/sky_logging.py | ||
"""Logging configuration for vLLM.""" | ||
import os | ||
import logging | ||
import sys | ||
|
||
|
||
log_levels = { | ||
"debug": logging.DEBUG, | ||
"info": logging.INFO, | ||
"warning": logging.WARNING, | ||
"error": logging.ERROR, | ||
"critical": logging.CRITICAL, | ||
} | ||
|
||
_FORMAT = "%(levelname)s %(asctime)s %(filename)s:%(lineno)d] %(message)s" | ||
_DATE_FORMAT = "%m-%d %H:%M:%S" | ||
|
||
|
||
class NewLineFormatter(logging.Formatter): | ||
class _NewLineFormatter(logging.Formatter): | ||
"""Adds logging prefix to newlines to align multi-line messages.""" | ||
|
||
def __init__(self, fmt, datefmt=None): | ||
|
@@ -26,15 +36,23 @@ def format(self, record): | |
_default_handler = None | ||
|
||
|
||
def _get_default_logging_level(): | ||
verbosity = os.getenv("VLLM_VERBOSITY", "info").lower() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For vLLM logs, we allow Users may want to set it to |
||
|
||
try: | ||
return log_levels[verbosity] | ||
except KeyError: | ||
raise ValueError(f"Unknown log level: {verbosity}") | ||
|
||
def _setup_logger(): | ||
_root_logger.setLevel(logging.DEBUG) | ||
_root_logger.setLevel(_get_default_logging_level()) | ||
global _default_handler | ||
if _default_handler is None: | ||
_default_handler = logging.StreamHandler(sys.stdout) | ||
_default_handler.flush = sys.stdout.flush # type: ignore | ||
_default_handler.setLevel(logging.INFO) | ||
_default_handler.setLevel(logging.DEBUG) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default handler goes down to |
||
_root_logger.addHandler(_default_handler) | ||
fmt = NewLineFormatter(_FORMAT, datefmt=_DATE_FORMAT) | ||
fmt = _NewLineFormatter(_FORMAT, datefmt=_DATE_FORMAT) | ||
_default_handler.setFormatter(fmt) | ||
# Setting this will avoid the message | ||
# being propagated to the parent logger. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we log only warnings and critical errors for
uvicorn
dependency (internal).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to omit this argument completely so that the
uvicorn
log level can be set with its own environment variable? See https://www.uvicorn.org/settings/