From c77f9150db30cd848d32f45b90cbb103c3f519db Mon Sep 17 00:00:00 2001 From: Tom Naessens Date: Tue, 9 Jun 2015 16:47:11 +0200 Subject: [PATCH] Add errbit integration --- app/app.py | 27 ++++++++++++++++++++++++--- app/config.example.py | 2 ++ requirements.txt | 17 ++++++++++++----- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/app/app.py b/app/app.py index b62b8bd..2875171 100644 --- a/app/app.py +++ b/app/app.py @@ -4,6 +4,8 @@ from flask import Flask from flask.ext.bootstrap import Bootstrap, StaticCDN from flask.ext.sqlalchemy import SQLAlchemy +from airbrake import Airbrake, AirbrakeHandler + app = Flask(__name__) app.config.from_object('config.Configuration') @@ -29,9 +31,28 @@ class PrefixFix(object): if not app.debug: app.wsgi_app = PrefixFix(app.wsgi_app, '/haldis') + timedFileHandler = TimedRotatingFileHandler(app.config['LOGFILE'], when='midnight', backupCount=100) timedFileHandler.setLevel(logging.DEBUG) - logger = logging.getLogger('werkzeug') - logger.setLevel(logging.DEBUG) - logger.addHandler(timedFileHandler) + + loglogger = logging.getLogger('werkzeug') + loglogger.setLevel(logging.DEBUG) + loglogger.addHandler(timedFileHandler) app.logger.addHandler(timedFileHandler) + + airbrakelogger = logging.getLogger('airbrake') + + # Airbrake + airbrake = Airbrake( + project_id=app.config['AIRBRAKE_ID'], + api_key=app.config['AIRBRAKE_KEY'] + ) + # ugly hack to make this work for out errbit + airbrake._api_url = "http://zeus-errbit.ilion.me/api/v3/projects/{}/notices".format(airbrake.project_id) + + airbrakelogger.addHandler( + AirbrakeHandler(airbrake=airbrake) + ) + app.logger.addHandler( + AirbrakeHandler(airbrake=airbrake) + ) diff --git a/app/config.example.py b/app/config.example.py index eaaebfd..4031e8e 100644 --- a/app/config.example.py +++ b/app/config.example.py @@ -8,3 +8,5 @@ class Configuration(object): LOGFILE = 'haldis.log' ZEUS_KEY = '' ZEUS_SECRET = '' + AIRBRAKE_ID = '' + AIRBRAKE_KEY = '' diff --git a/requirements.txt b/requirements.txt index 29c7cb8..ed260b9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,16 +2,23 @@ Flask==0.10.1 Flask-Admin==1.1.0 Flask-Bootstrap==3.3.4.1 Flask-Login==0.2.11 +Flask-Migrate==1.4.0 Flask-OAuthlib==0.9.1 Flask-SQLAlchemy==2.0 +Flask-Script==2.0.5 Flask-WTF==0.11 -Flask-Migrate==1.4.0 -itsdangerous==0.24 Jinja2==2.7.3 +Mako==1.0.1 MarkupSafe==0.23 -oauthlib==0.7.2 PyMySQL==0.6.6 -requests==2.7.0 SQLAlchemy==1.0.4 -Werkzeug==0.10.4 WTForms==2.0.2 +Werkzeug==0.10.4 +airbrake==1.1.4 +alembic==0.7.6 +blinker==1.3 +itsdangerous==0.24 +oauthlib==0.7.2 +requests==2.7.0 +requests-oauthlib==0.5.0 +six==1.9.0