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)
posted on 2021-01-20 22:48  多多洛~吖  阅读(330)  评论(0)    收藏  举报