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:
    logging.debug(linecache.getline(__file__, inspect.getlineno(inspect.
        currentframe()) - 1))
if __name__ == '__main__':
    main()
How to print source code lines in python logger