Airbrake client for Python Flask Microframework
Licensed under the MIT License.
To run tests, you need to install some required packages. Remember to activate your virtualenv first.
# install required packages for test
$ pip install -e .[test]
# run test
$ make test
# generate coverage report
$ make cover
from flask import Flask, request, got_request_exception
from airbrake.airbrake import AirbrakeErrorHandler
import gevent
import sys
app = Flask(__name__)
ENV = ('ENV' in os.environ and os.environ['ENV']) or 'prod'
def log_exception(error):
handler = AirbrakeErrorHandler(api_key="PUT_YOUR_AIRBRAKE_KEY_HERE",
env_name=ENV,
request=request)
gevent.spawn(handler.emit, error, sys.exc_info())
got_request_exception.connect(log_exception, app)