import sys def info type value tb if hasattr sys ps1 or not sys stderr

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
import sys
def info(type, value, tb):
if hasattr(sys, 'ps1') or not sys.stderr.isatty():
sys.__excepthook__(type, value, tb)
else:
import traceback, pdb
traceback.print_exception(type, value, tb)
print
pdb.post_mortem(tb)
sys.excepthook = info
import logging
FORMAT = '%(asctime)-15s %(filename)s:%(lineno)d\t%(funcName)s %(message)s'
logging.basicConfig(format=FORMAT, level=logging.INFO)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.debug("CheckDebug")
logger.info("CheckInfo")