Created
June 14, 2018 14:02
-
-
Save bekce/1f734cee3e91f39f17c3bdb29c476bc5 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 logging.handlers | |
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)-10s %(message)s' ) | |
smtp_handler = logging.handlers.SMTPHandler(mailhost=("localhost", 25), | |
fromaddr="from@example.com", | |
toaddrs=["admin@example.com"], | |
subject=u"stuff failed") | |
mail_logger = logging.getLogger("mail") | |
mail_logger.addHandler(smtp_handler) | |
try: | |
raise Exception('test', 'exception') | |
except Exception as e: | |
logging.warning("normal log") | |
mail_logger.warning("exception!! " + str(e)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment