Hi everybody,
While I receive error mails in my development setup (on localhost) I dont get them in my 'production' setup on pythonanywhere. I use the code from the Flask Error Handling Docs.
When I catch exceptions I use
app.log_exception(exc)
in order to send the exception into the pipeline to eventually receive mails.
Could you help me out here? What am I possibly doing wrong?
Kind regards, Tom
run.py:
#!flask/bin/python
from app import app
if __name__ == '__main__':
if not app.debug:
import logging
from logging.handlers import SMTPHandler
from logging import Formatter
mail_handler = SMTPHandler(app.config['MAIL_SERVER'],
app.config['MAIL_DEFAULT_SENDER'],
app.config['MAIL_ERROR_RECIPIENT'],
app.config['MAIL_ERROR_SUBJECT'],
credentials=(app.config['MAIL_USERNAME'],
app.config['MAIL_PASSWORD']),
secure=())
mail_handler.setLevel(logging.ERROR)
mail_handler.setFormatter(Formatter('''
Message type: %(levelname)s
Location: %(pathname)s:%(lineno)d
Module: %(module)s
Function: %(funcName)s
Time: %(asctime)s
Message:
%(message)s
'''))
app.logger.addHandler(mail_handler)
app.run()