Flask-Exceptional adds Exceptional support to Flask. Exceptional tracks errors in your application, reports them real-time, and gathers the info you need to fix them fast. Visit http://www.exceptional.io to give it a try.
The remaining documentation assumes you have access to an Exceptional account. Installing the extension is simple with pip:
$ pip install Flask-Exceptional
or alternatively with easy_install:
$ easy_install Flask-Exceptional
After installing Flask-Exceptional, all you have to do is create a Flask application, configure the Exceptional API key, and create the Exceptional object. It’s this easy:
from flask import Flask from flask.ext.exceptional import Exceptional app = Flask(__name__) app.config["EXCEPTIONAL_API_KEY"] = "exceptional_forty_character_unique_key" exceptional = Exceptional(app)
Your application is configured for cloud-based error monitoring! You can verify your configuration is working by calling the Exceptional.test() method:
Check out the following section for more detail on the available Flask-Exceptional configuration settings.
The following configuration settings exist for Flask-Exceptional:
The Exceptional API key for your application. Login to Exceptional, select your app, and click the APP SETTINGS link. The displayed API key is the value to use here.
Attempting to create the extension without supplying an API key will result in a logged warning, but the app will continue to run as normal.
|EXCEPTIONAL_DEBUG_URL||If your app is running in debug mode, errors are not tracked with Exceptional. Configure this value to capture error data in debug mode. For example, you may use a RequestBin URL to debug your application. JSON error data is POSTed uncompressed to this URL, whereas Exceptional requires the data to be compressed.|
A list of codes for HTTP errors that will be tracked with Exceptional.
Defaults to standard HTTP 4xx codes.
A list of values to filter from the parameter data sent to Exceptional. Parameter data includes everything in request.form and request.files.
For example, to filter passwords you might use:
A list of values to filter from the environment data sent to Exceptional. The environment data includes the Flask application config plus the current OS environment. OS environment values are prefixed by 'os.'.
For example, to filter the SQL Alchemy database URI and all OS environment values, use:
Defaults to ['SECRET_KEY']
|EXCEPTIONAL_SESSION_FILTER||A list of values to filter from the session data sent to Exceptional.|
|EXCEPTIONAL_HEADER_FILTER||A list of values to filter from the HTTP header data sent to Exceptional.|
|EXCEPTIONAL_COOKIE_FILTER||A list of names to filter from the HTTP Cookie header data sent to Exceptional.|
All configuration filter lists accept both strings and regular expression patterns.
Extension for tracking application errors with Exceptional. Errors are not tracked if DEBUG is True. The application will log a warning if no EXCEPTIONAL_API_KEY has been configured.
|Parameters:||app – Default None. The Flask application to track errors for. If the app is not provided on creation, then it can be provided later via init_app().|
Add extra context data to the current tracked exception. The context data is only valid for the current request. Multiple calls to this method will update any existing context with new data.
Initialize this Exceptional extension.
|Parameters:||app – The Flask application to track errors for.|
Publish the given traceback directly to Exceptional. This method is useful for tracking errors that occur outside the context of a Flask request. For example, this may be called from an asynchronous queue.
Test the given Flask configuration. If configured correctly, an error will be tracked by Exceptional for your app. Unlike the initialized extension, this test will post data to Exceptional, regardless of the configured DEBUG setting.
|Parameters:||config – The Flask application configuration object to test. Accepts either flask.Config or the object types allowed by flask.Config.from_object().|