This commit is contained in:
2025-08-20 04:15:43 +02:00
parent 6b9f0cf291
commit e4bb201181
95 changed files with 194 additions and 907 deletions

39
herolib/tools/logger.py Normal file
View File

@@ -0,0 +1,39 @@
import logging
import colorlog
log_colors_config = {
'DEBUG': 'cyan',
'INFO': 'green',
'WARNING': 'yellow',
'ERROR': 'red',
'CRITICAL': 'bold_red',
}
secondary_log_colors_config = {
'name': {
'DEBUG': 'blue',
'INFO': 'blue',
'WARNING': 'blue',
'ERROR': 'blue',
'CRITICAL': 'blue'
},
'levelname': log_colors_config
}
formatter = colorlog.ColoredFormatter(
'%(log_color)s%(asctime)s - %(name_log_color)s%(name)s - %(levelname_log_color)s%(levelname)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
log_colors=log_colors_config,
secondary_log_colors=secondary_log_colors_config
)
# Create a handler
handler = logging.StreamHandler()
handler.setFormatter(formatter)
# Get the root logger
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
logger.addHandler(handler)