fmt
All checks were successful
Deploy to core / deploy (push) Successful in 2m0s

This commit is contained in:
2024-02-21 10:27:16 +03:00
parent 4f26812340
commit 7cf702eb98
35 changed files with 1059 additions and 825 deletions

View File

@@ -3,19 +3,19 @@ import colorlog
# Define the color scheme
color_scheme = {
'DEBUG': 'light_black',
'INFO': 'green',
'WARNING': 'yellow',
'ERROR': 'red',
'CRITICAL': 'red,bg_white',
"DEBUG": "light_black",
"INFO": "green",
"WARNING": "yellow",
"ERROR": "red",
"CRITICAL": "red,bg_white",
}
# Define secondary log colors
secondary_colors = {
'log_name': {'DEBUG': 'blue'},
'asctime': {'DEBUG': 'cyan'},
'process': {'DEBUG': 'purple'},
'module': {'DEBUG': 'light_black,bg_blue'},
"log_name": {"DEBUG": "blue"},
"asctime": {"DEBUG": "cyan"},
"process": {"DEBUG": "purple"},
"module": {"DEBUG": "light_black,bg_blue"},
}
# Define the log format string
@@ -23,30 +23,30 @@ fmt_string = "%(log_color)s%(levelname)s: %(log_color)s[%(module)s]%(reset)s %(w
# Define formatting configuration
fmt_config = {
'log_colors': color_scheme,
'secondary_log_colors': secondary_colors,
'style': '%',
'reset': True
"log_colors": color_scheme,
"secondary_log_colors": secondary_colors,
"style": "%",
"reset": True,
}
class MultilineColoredFormatter(colorlog.ColoredFormatter):
def format(self, record):
# Check if the message is multiline
if record.getMessage() and '\n' in record.getMessage():
if record.getMessage() and "\n" in record.getMessage():
# Split the message into lines
lines = record.getMessage().split('\n')
lines = record.getMessage().split("\n")
formatted_lines = []
for line in lines:
# Format each line with the provided format
formatted_lines.append(super().format(record))
# Join the formatted lines
return '\n'.join(formatted_lines)
return "\n".join(formatted_lines)
else:
# If not multiline or no message, use the default formatting
return super().format(record)
# Create a MultilineColoredFormatter object for colorized logging
formatter = MultilineColoredFormatter(fmt_string, **fmt_config)
@@ -55,8 +55,7 @@ stream = logging.StreamHandler()
stream.setFormatter(formatter)
def get_colorful_logger(name='main'):
def get_colorful_logger(name="main"):
# Create and configure the logger
logger = logging.getLogger(name)
logger.setLevel(logging.DEBUG)
@@ -64,6 +63,7 @@ def get_colorful_logger(name='main'):
return logger
# Set up the root logger with the same formatting
root_logger = logging.getLogger()
root_logger.setLevel(logging.DEBUG)