Created
February 22, 2019 16:02
-
-
Save IlianIliev/710d0eab809f5b328af163ee9fe8a1f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import sys | |
logging.basicConfig(filename='mybot.log', level=logging.DEBUG, | |
format='%(asctime)s: %(name)s: %(levelname)s: %(message)s') | |
logger = logging.getLogger(__name__) | |
logger.info('Start') | |
def log_uncaught_exception(exctype, value, traceback): | |
logger.error('Unhandled Exception caught', exc_info=(exctype, value, traceback)) | |
sys.excepthook = log_uncaught_exception | |
try: | |
1/0 | |
except: | |
logger.error('ERrrrrrrorrr') | |
logger.info('End') | |
1/0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment