Add sentry exception monitoring.

This commit is contained in:
Jake Moshenko 2014-04-28 18:59:22 -04:00
parent b30d0976f0
commit fe665118bb
8 changed files with 77 additions and 8 deletions

28
util/exceptionlog.py Normal file
View file

@ -0,0 +1,28 @@
from raven.contrib.flask import Sentry as FlaskSentry
class FakeSentry(object):
pass
class Sentry(object):
def __init__(self, app=None):
self.app = app
if app is not None:
self.state = self.init_app(app)
else:
self.state = None
def init_app(self, app):
sentry_type = app.config.get('EXCEPTION_LOG_TYPE', 'FakeSentry')
if sentry_type == 'Sentry':
sentry = FlaskSentry(app)
else:
sentry = FakeSentry()
# register extension with app
app.extensions = getattr(app, 'extensions', {})
app.extensions['sentry'] = sentry
return sentry
def __getattr__(self, name):
return getattr(self.state, name, None)