Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. if __name__ == '__main__':
  2. try:
  3. #my code
  4. catch:
  5. exc_logger.exception('Guys, can we fix this?')
  6.  
  7. class ExceptionRecorder(object):
  8. def __init__(self, exc_logger):
  9. self.exc_logger = exc_logger
  10.  
  11. def __enter(self):
  12. pass
  13.  
  14. def __exit__(self, exc_type, exc_value, traceback):
  15. if exc_value:
  16. self.exc_logger.error('Program terminated with the following: ', exc_value)
  17.  
  18. return True
  19.  
  20. if __name__ == '__main__':
  21. with ExceptionRecorder(logger.getLogger('oh_no')):
  22. #run the program code here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement