def wrapper(*args, **kwargs): fname = '%s.%s' % (f.__module__, f.__name__) _args = ', '.join( chain( (repr(arg) for arg in args), ('%s=%s' % (k, repr(v)) for (k, v) in kwargs.items()), )) if with_args else '...' _debug.begin('%s(%s): ...' % (fname, _args)) try: ret = f(*args, **kwargs) except: try: (exctype, value) = sys.exc_info()[:2] _debug.end('%s(...): %s(%s)' % (fname, exctype, value)) finally: exctype = value = None raise else: _debug.end('%s(...): %s' % (fname, repr(ret) if with_return else '...')) return ret
def __del__(self): """ Log the end of function. """ _debug.end(self.fname)