Is there a relatively easy way to programmatically include lines of source code in a python log report. For example...
import logging def main(): something_is_not_right = True logging.basicConfig(level=logging.DEBUG, format=('%(filename)s: ' '%(levelname)s: ' '%(funcName)s(): ' '%(lineno)d:\t' '%(message)s') ) if something_is_not_right == True: logging.debug('some way to get previous line of source code here?')
Thus, the output will look as follows.
example.py: DEBUG: main(): 14: if something_is_not_right == True:
python debugging logging
ojs
source share