librelist archives

« back to archive

SMTP logger fails when used with flask-script

SMTP logger fails when used with flask-script

From:
Sean Whalen
Date:
2012-12-23 @ 14:55
Hi all,

I set up the following logger based on
http://flask.pocoo.org/docs/errorhandling/:

if not app.debug:
    mail_handler = SMTPHandler(app.config['MAIL_SERVER'],
                               app.config['DEFAULT_MAIL_SENDER'],
                               [app.config['ADMIN_MAIL']],
                               'Application Failed',
                               credentials=(app.config['MAIL_USERNAME'],
                               app.config['MAIL_PASSWORD']),
                               secure=())
    mail_handler.setLevel(logging.ERROR)
    app.logger.addHandler(mail_handler)

It works great for logging exceptions caused by web requests, but the
same code does not seem to respond exceptions that are raised when a
flask-script command is executed. How can I fix this?

-- 
Sean whalen

Re: [flask] SMTP logger fails when used with flask-script

From:
Sean Lynch
Date:
2012-12-23 @ 15:27
You might need to set "passthrough_errors = True' for the server.  See:
http://werkzeug.pocoo.org/docs/serving/

Note this was added in 0.5.1.


On Sun, Dec 23, 2012 at 9:55 AM, Sean Whalen <whalenster@gmail.com> wrote:

> Hi all,
>
> I set up the following logger based on
> http://flask.pocoo.org/docs/errorhandling/:
>
> if not app.debug:
>     mail_handler = SMTPHandler(app.config['MAIL_SERVER'],
>                                app.config['DEFAULT_MAIL_SENDER'],
>                                [app.config['ADMIN_MAIL']],
>                                'Application Failed',
>                                credentials=(app.config['MAIL_USERNAME'],
>                                app.config['MAIL_PASSWORD']),
>                                secure=())
>     mail_handler.setLevel(logging.ERROR)
>     app.logger.addHandler(mail_handler)
>
> It works great for logging exceptions caused by web requests, but the
> same code does not seem to respond exceptions that are raised when a
> flask-script command is executed. How can I fix this?
>
> --
> Sean whalen
>
>

Re: [flask] SMTP logger fails when used with flask-script

From:
Sean Whalen
Date:
2012-12-23 @ 15:37
The script in question is being run on a scheduled basis, independent 
of WSGI.


On Sunday, December 23, 2012 10:27:05 AM, Sean Lynch wrote:
> You might need to set "passthrough_errors = True' for the server.
>  See: http://werkzeug.pocoo.org/docs/serving/
>
> Note this was added in 0.5.1.
>
>
> On Sun, Dec 23, 2012 at 9:55 AM, Sean Whalen <whalenster@gmail.com
> <mailto:whalenster@gmail.com>> wrote:
>
>     Hi all,
>
>     I set up the following logger based on
>     http://flask.pocoo.org/docs/errorhandling/:
>
>     if not app.debug:
>         mail_handler = SMTPHandler(app.config['MAIL_SERVER'],
>                                    app.config['DEFAULT_MAIL_SENDER'],
>                                    [app.config['ADMIN_MAIL']],
>                                    'Application Failed',
>
>      credentials=(app.config['MAIL_USERNAME'],
>                                    app.config['MAIL_PASSWORD']),
>                                    secure=())
>         mail_handler.setLevel(logging.ERROR)
>         app.logger.addHandler(mail_handler)
>
>     It works great for logging exceptions caused by web requests, but the
>     same code does not seem to respond exceptions that are raised when a
>     flask-script command is executed. How can I fix this?
>
>     --
>     Sean whalen
>
>