python+pytest打印日志
2021-01-22 10:15
标签:turn 模块 debug ret info *args 日期格 mic file 使用python自带的logging日志模块 python+pytest打印日志 标签:turn 模块 debug ret info *args 日期格 mic file 原文地址:https://www.cnblogs.com/panda-123/p/14305592.html1.简单设置
import logging
# 设置log级别为 info
logging.basicConfig(level=logging.INFO)
# error > debug > info
def run(*args, **kwargs):
basepage = args[0]
try:
logging.info(f"start find:{str(args)},开始找 KWARGS:{str(kwargs)}")
return fun(*args, **kwargs)
2.加入日期格式的日志
import logging
LOG_FORMAT = "%(asctime)s - %(levelname)s - %(message)s"
logging.basicConfig(filename=‘xueqiu.log‘, level=logging.INFO, format=LOG_FORMAT)