logging_helper Package¶
logging_helper
Module¶
-
logging_helper.
log_stack
(logger=None, limit=None, start=0)[source]¶ Prints the call stack at the point of the caller to the given log.
Example:
>>> import logging >>> logger = logging.getLogger(__name__) >>> logger.setLevel(logging.DEBUG) >>> >>> import logging_helper >>> >>> def outer(): ... middle() >>> >>> def middle(): ... inner() >>> >>> def inner(): ... logging_helper.log_stack(logger, 2) >>> >>> outer() 130424-12:17:35,722 __main__ DEBUG: Call stack at /snippet/test_logging_helper.py, line 13 in function inner, frames 2 to 3 of 11: 130424-12:17:35,722 __main__ DEBUG: /snippet/test_logging_helper.py, line 10 in function middle. 130424-12:17:35,722 __main__ DEBUG: /snippet/test_logging_helper.py, line 7 in function outer.
Parameters: - logger – the logger to use (default is the root logger)
- limit – the number of frames to print (default prints all remaining frames)
- start – the offset of the first frame preceding the caller to print (default is 0)