Move files
This commit is contained in:
parent
3cf28379e8
commit
00cc8225c5
159 changed files with 31 additions and 49 deletions
21
great_ai/utilities/logger/custom_formatter.py
Normal file
21
great_ai/utilities/logger/custom_formatter.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import logging
|
||||
|
||||
from .colors import BLUE, BOLD_RED, GREY, RED, RESET, YELLOW
|
||||
|
||||
|
||||
class CustomFormatter(logging.Formatter):
|
||||
def __init__(self, fmt: str):
|
||||
super().__init__()
|
||||
self._fmt = fmt
|
||||
self._color_mapping = {
|
||||
logging.DEBUG: GREY + self._fmt + RESET,
|
||||
logging.INFO: BLUE + self._fmt + RESET,
|
||||
logging.WARNING: YELLOW + self._fmt + RESET,
|
||||
logging.ERROR: RED + self._fmt + RESET,
|
||||
logging.CRITICAL: BOLD_RED + self._fmt + RESET,
|
||||
}
|
||||
|
||||
def format(self, record: logging.LogRecord) -> str:
|
||||
log_fmt = self._color_mapping.get(record.levelno)
|
||||
formatter = logging.Formatter(log_fmt)
|
||||
return formatter.format(record)
|
||||
Loading…
Add table
Add a link
Reference in a new issue