3 ms·
import logging import threading logger = logging.getLogger(__name__) def log(fn): def log_inner(*a, **kw): logger.info('%s(%s,
by shakna 5y ago
import logging
import threading
logger = logging.getLogger(__name__)
def log(fn):
def log_inner(*a, **kw):
logger.info('%s(%s, %s) @ %s', fn, a, kw, threading.get_native_id())
return fn(*a, **kw)
return log_inner
It's pretty easy to grab all the arguments and thread, but grabbing the return would depend on you not mutating anything permanent, so that probably needs some special casing.
- bckr 4y agoThanks for typing that up! The test will be whether this will help as much as I think it would in a real system.