Guest User

Untitled

a guest
Oct 22nd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. # vim: set expandtab ts=4 sw=4 filetype=python:
  2.  
  3. import logging
  4. import sys
  5. import traceback
  6.  
  7. def f():
  8.  
  9. return g()
  10.  
  11. def g():
  12.  
  13. return h()
  14.  
  15. def h():
  16.  
  17. return i()
  18.  
  19. def i():
  20.  
  21. 1/0
  22.  
  23. def log_uncaught_exceptions(ex_cls, ex, tb):
  24. logging.critical(''.join(traceback.format_tb(tb)))
  25. logging.critical('{0}: {1}'.format(ex_cls, ex))
  26.  
  27. if __name__ == '__main__':
  28.  
  29. sys.excepthook = log_uncaught_exceptions
  30.  
  31. logging.basicConfig(level=logging.DEBUG)
  32. logging.debug('About to do f().')
  33.  
  34. f()
  35.  
  36. # You will never see this logging statement.
  37. logging.debug('All finished!')
Add Comment
Please, Sign In to add comment