log.py 文件源码

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

项目:behem0th 作者: robot0nfire 项目源码 文件源码
def _print(str, *args, **kwargs):
    if NO_LOG:
        return

    str = Formatter().vformat(str, args, kwargs)
    str = str.replace('\n', '\n' + ' ' * 11)

    stack = inspect.stack()

    # Stack depth has to be atleast 3 normally, since _print() should
    # be normally only be called from info{_v}(), warn() or error().
    # But we still take care of edge cases where this may not be true.
    frame = stack[2][0] if len(stack) >= 3 else None
    class_ = frame.f_locals['self'].__class__.__name__ if frame and 'self' in frame.f_locals else '<unknown>'
    thread = threading.current_thread().name

    print(BEHEM0TH_COLOR + '[behem0th]',
        CLASS_COLOR + '[' + class_ + ']',
        THREAD_COLOR + thread + ':', str, CLEAR_FORMAT)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号