如何在不创建记录器的情况下记录警告?
How to log a warning without creating a logger?
如何在不创建记录器的情况下记录警告 python?我还想确保它确实正确记录。
是:
import logging
logging.warning('warning')
够了吗?
年份:
import logging
logging.warning('warning with real information from your code')
输出:
WARNING:root:warning
据我了解,您希望在不设置记录器的情况下进行记录。如果您不介意安装第三方包,请查看 loguru。
这是 ready to use out of the box 没有样板:
from loguru import logger
logger.warning("That's it, beautiful and simple logging!")
查看文档以获取更多信息。
如何在不创建记录器的情况下记录警告 python?我还想确保它确实正确记录。
是:
import logging
logging.warning('warning')
够了吗?
年份:
import logging
logging.warning('warning with real information from your code')
输出:
WARNING:root:warning
据我了解,您希望在不设置记录器的情况下进行记录。如果您不介意安装第三方包,请查看 loguru。 这是 ready to use out of the box 没有样板:
from loguru import logger
logger.warning("That's it, beautiful and simple logging!")
查看文档以获取更多信息。