logger-improved
All checks were successful
Deploy on push / deploy (push) Successful in 29s

This commit is contained in:
2024-02-27 16:33:25 +03:00
parent eb295549fb
commit 4c328370c2
2 changed files with 3 additions and 6 deletions

View File

@@ -16,10 +16,11 @@ secondary_colors = {
'asctime': {'DEBUG': 'cyan'},
'process': {'DEBUG': 'purple'},
'module': {'DEBUG': 'light_black,bg_blue'},
'funcName': {'DEBUG': 'light_white,bg_blue'}, # Add this line
}
# Define the log format string
fmt_string = '%(log_color)s%(levelname)s: %(log_color)s[%(module)s]%(reset)s %(white)s%(message)s'
fmt_string = '%(log_color)s%(levelname)s: %(log_color)s[%(module)s.%(funcName)s]%(reset)s %(white)s%(message)s'
# Define formatting configuration
fmt_config = {
@@ -29,7 +30,6 @@ fmt_config = {
'reset': True,
}
class MultilineColoredFormatter(colorlog.ColoredFormatter):
def format(self, record):
# Check if the message is multiline
@@ -46,7 +46,6 @@ class MultilineColoredFormatter(colorlog.ColoredFormatter):
# 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)
@@ -54,7 +53,6 @@ formatter = MultilineColoredFormatter(fmt_string, **fmt_config)
stream = logging.StreamHandler()
stream.setFormatter(formatter)
def get_colorful_logger(name='main'):
# Create and configure the logger
logger = logging.getLogger(name)
@@ -63,7 +61,6 @@ 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)