Nove zavislosti, logovani, refaktoring

This commit is contained in:
Michal Kváček
2025-04-03 17:35:50 +02:00
parent a7fda95c29
commit 71911c0905
8 changed files with 74 additions and 34 deletions
+16 -10
View File
@@ -1,22 +1,28 @@
import logging
import sys
from colorlog import ColoredFormatter
log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)
# Create handlers for logging to the standard output and a file
stdoutHandler = logging.StreamHandler(stream=sys.stdout)
# Set the log levels on the handlers
stdoutHandler.setLevel(logging.DEBUG)
# Create a log format using Log Record attributes
fmt = logging.Formatter(
"%(name)s: %(asctime)s | %(levelname)s | %(filename)s:%(lineno)s | %(process)d >>> %(message)s"
fmt = ColoredFormatter(
"%(log_color)s[%(levelname)s]%(reset)s %(blue)s%(message)s%(reset)s %(light_black)s[%(filename)s:%(lineno)d]]%(reset)s",
datefmt=None,
reset=True,
log_colors={
'DEBUG': 'cyan',
'INFO': 'green',
'WARNING': 'yellow',
'ERROR': 'red',
'CRITICAL': 'red,bg_white',
},
secondary_log_colors={},
style='%'
)
# Set the log format on each handler
stdoutHandler.setFormatter(fmt)
# Add each handler to the Logger object
log.addHandler(stdoutHandler)