log.py 文件源码

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

项目:better-exceptions 作者: Qix- 项目源码 文件源码
def patch():
    import logging
    from . import format_exception

    logging_format_exception = lambda exc_info: format_exception(*exc_info)

    if hasattr(logging, '_defaultFormatter'):
        logging._defaultFormatter.format_exception = logging_format_exception

    patchables = [handler() for handler in logging._handlerList if isinstance(handler(), StreamHandler)]
    patchables = [handler for handler in patchables if handler.stream == sys.stderr]
    patchables = [handler for handler in patchables if handler.formatter is not None]
    for handler in patchables:
        handler.formatter.formatException = logging_format_exception
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号