This repository has been archived by the owner on Oct 11, 2024. It is now read-only.
forked from vllm-project/vllm
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import logging | ||
|
||
|
||
def make_logger(name: str) -> logging.Logger: | ||
"""Create a base logger""" | ||
|
||
logger = logging.getLogger(name) | ||
logger.setLevel(logging.DEBUG) | ||
stream_handler = logging.StreamHandler() | ||
formatter = logging.Formatter( | ||
"%(asctime)s - %(levelname)s - %(name)s - %(message)s", | ||
datefmt="%Y-%m-%d %H:%M:%S", | ||
) | ||
stream_handler.setFormatter(formatter) | ||
logger.addHandler(stream_handler) | ||
return logger | ||
|
||
|
||
def log_banner(logger: logging.Logger, | ||
label: str, | ||
body: str, | ||
level: int = logging.INFO): | ||
""" | ||
Log a message in the "banner"-style format. | ||
:param logger: Instance of "logging.Logger" to use | ||
:param label: Label for the top of the banner | ||
:param body: Body content inside the banner | ||
:param level: Logging level to use (default: INFO) | ||
""" | ||
|
||
banner = f"==== {label} ====\n{body}\n====" | ||
logger.log(level, "\n%s", banner) |