def intialize_logging(debug):
"""
Initialize the logging framework using the Safe Eyes specific configurations.
"""
# Configure logging.
root_logger = logging.getLogger()
log_formatter = logging.Formatter('%(asctime)s [%(levelname)s]:[%(threadName)s] %(message)s')
# Append the logs and overwrite once reached 1MB
if debug:
# Log to file
file_handler = RotatingFileHandler(LOG_FILE_PATH, maxBytes=1024 * 1024, backupCount=5, encoding=None, delay=0)
file_handler.setFormatter(log_formatter)
# Log to console
console_handler = logging.StreamHandler()
console_handler.setFormatter(log_formatter)
root_logger.setLevel(logging.DEBUG)
root_logger.addHandler(console_handler)
root_logger.addHandler(file_handler)
else:
root_logger.propagate = False
评论列表
文章目录