debug.py 文件源码

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

项目:omniduct 作者: airbnb 项目源码 文件源码
def logging_scope(name, *wargs, **wkwargs):
    '''
    A decorator to add the decorated function as a new logging scope, with name `name`.
    All additional arguments are passed to `StatusLogger._scope_enter`. Current
    supported keyword arguments are "timed", in which case when the scope closes,
    the duration of the call is shown.
    '''
    def logging_scope(func, *args, **kwargs):
        logger._scope_enter(name, *wargs, **wkwargs)
        success = True
        try:
            f = func(*args, **kwargs)
            return f
        except Exception as e:
            success = False
            raise_with_traceback(e)
        finally:
            logger._scope_exit(success)
    return lambda func: decorate(func, logging_scope)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号