slogging.py 文件源码

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

项目:pyethereum 作者: ethereumproject 项目源码 文件源码
def _inject_into_logger(name, code, namespace=None):
    # This is a hack to fool the logging module into reporting correct source files.
    # It determines the actual source of a logging call by inspecting the stack frame's
    # source file. So we use this `eval(compile())` construct to "inject" our additional
    # methods into the logging module.
    if namespace is None:
        namespace = {}
    eval(
        compile(
            code,
            logging._srcfile,
            'exec'
        ),
        namespace
    )
    setattr(logging.Logger, name, namespace[name])


# Add `trace()` level to Logger
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号