详细可参考

logging配置

https://blog.csdn.net/zyz511919766/article/details/25136485

pytest中输出日志

https://www.cnblogs.com/landhu/p/9910460.html

简单的example

def test_logging():
    # logging.basicConfig(level=logging.DEBUG,
    #                     format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
    #                     datefmt='%a, %d %b %Y %H:%M:%S',
    #                     filename='/tmp/test.log',
    #                     filemode='w')
    logging.basicConfig(level=logging.DEBUG)
    logging.debug('debug message')
    logging.info('info message')
    logging.warning('warning message')
    logging.error('error message')
    logging.critical('critical message')

pycharm中的 Additional Arguments设置为 -s --capture=no -o log_cli=true -o log_cli_level=DEBUGpytest 打印日志

 

 

 

相关文章:

  • 2021-10-28
  • 2022-02-05
  • 2021-09-20
  • 2021-09-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2021-10-11
  • 2022-01-31
相关资源
相似解决方案