Add sentry exception monitoring.
This commit is contained in:
parent
b30d0976f0
commit
fe665118bb
8 changed files with 77 additions and 8 deletions
28
util/exceptionlog.py
Normal file
28
util/exceptionlog.py
Normal 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)
|
Reference in a new issue