首页 > 解决方案 > 如何在 Python 中显示日志消息

问题描述

我需要在调试时显示日志消息,我应该如何使用如下代码显示消息:

logs.out("Here are the error messages")
logs.clear()

标签: error-logging

解决方案


您应该使用日志库,这是一个示例:

import logging

logging.debug('debug message')
logging.info('information message')
logging.warning('A warning message')
logging.error('Error Description')
logging.critical('Critical messages should be here')

推荐阅读