_logging.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:maas 作者: maas 项目源码 文件源码
def configure_standard_logging(verbosity: int, mode: LoggingMode):
    """Configure the standard library's `logging` module.

    Get `logging` working with options consistent with Twisted. NOTE CAREFULLY
    that `django.utils.log.DEFAULT_LOGGING` may have been applied (though only
    if installed and if configured in this environment). Those settings and
    the settings this function applies must be mentally combined to understand
    the resultant behaviour.

    :param verbosity: See `get_logging_level`.
    :param mode: The mode in which to configure logging. See `LoggingMode`.
    """
    set_standard_verbosity(verbosity)
    # Make sure that `logging` is not configured to capture warnings.
    logging.captureWarnings(False)
    # If a logger is ever configured `propagate=False` but without handlers
    # `logging.Logger.callHandlers` will employ the `lastResort` handler in
    # order that the log is not lost. This goes to standard error by default.
    # Here we arrange for these situations to be logged more distinctively so
    # that they're easier to diagnose.
    logging.lastResort = (
        logging.StreamHandler(
            twistedModern.LoggingFile(
                logger=twistedModern.Logger("lost+found"),
                level=twistedModern.LogLevel.error)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号