Created
July 19, 2014 10:39
-
-
Save Jc2k/3794efa6faf777b35176 to your computer and use it in GitHub Desktop.
Call logging decorator (probably doesn't work, found it when having a spring clean)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logger | |
log = logger.getLogger(__name__) | |
def log_calls(fn): | |
def inner(*args, **kwargs): | |
f = inspect.currentframe() | |
frame, filename, line, func_name, lines, index = inspect.getouterframes(f)[1] | |
args = inspect.getargvalues(f) | |
log.info("%s called by %s (line %d in %s). Args: %s" % (fn, func_name, line, filename, args)) | |
return fn(*args, **kwargs) | |
return inner | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment