Skip to content

Instantly share code, notes, and snippets.

@dustinvtran
Created March 18, 2019 18:48
Show Gist options
  • Save dustinvtran/02254a0dde7e1c55c4f52f68258e20dc to your computer and use it in GitHub Desktop.
Save dustinvtran/02254a0dde7e1c55c4f52f68258e20dc to your computer and use it in GitHub Desktop.
TRACE_STACK = [lambda f, *args, **kwargs: f(*args, **kwargs)]
@contextmanager
def trace(tracer):
TRACE_STACK.append(tracer)
yield
TRACE_STACK.pop()
def traceable(func):
def func_wrapped(*args, **kwargs):
return TRACE_STACK[-1](func, *args, **kwargs)
return func_wrapped
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment