python+pytest打印日志
使用python自带的logging日志模块
1.简单设置
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)
浙公网安备 33010602011771号