def configure_logging():
root_logger = logging.getLogger()
console = logging.StreamHandler()
console.setLevel(logging.DEBUG)
# Create a colorized formatter
formatter = ColoredFormatter(
"%(log_color)s%(levelname)-8s%(reset)s %(blue)s%(message)s",
datefmt=None,
reset=True,
log_colors={
"DEBUG": "cyan",
"INFO": "green",
"WARNING": "yellow",
"ERROR": "red",
"CRITICAL": "red,bg_white",
},
secondary_log_colors={},
style="%"
)
# Add the formatter to the console handler, and the console
# handler to the root logger.
console.setFormatter(formatter)
root_logger.addHandler(console)
评论列表
文章目录