python logging 应用记录
如果只想在执行文件输出,不想引入的包输出
import logging
logsss = logging.getLogger(__name__)
logsss.setLevel(logging.INFO)
console_handler = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
console_handler.setFormatter(formatter)
# 将处理器添加到日志记录器
logsss.addHandler(console_handler)