Adds Rollbar support for exceptions

Also formats exceptions in case they are unprintable
This commit is contained in:
Ilan Steemers
2016-01-07 18:50:55 +01:00
parent edb0ffbed3
commit d29c861d09
4 changed files with 28 additions and 4 deletions
+18
View File
@@ -128,6 +128,9 @@ class Conf(object):
# The redis stats key
Q_STAT = 'django_q:{}:cluster'.format(PREFIX)
# Optional Rollbar key
ROLLBAR = conf.get('rollbar', {})
# OSX doesn't implement qsize because of missing sem_getvalue()
try:
QSIZE = Queue().qsize() == 0
@@ -160,6 +163,21 @@ if not logger.handlers:
handler.setFormatter(formatter)
logger.addHandler(handler)
# rollbar
if Conf.ROLLBAR:
rollbar_conf = Conf.ROLLBAR
try:
import rollbar
rollbar.init(rollbar_conf.pop('access_token'), environment=rollbar_conf.pop('environment'), **rollbar_conf)
except ImportError:
rollbar = None
else:
rollbar = None
# get parent pid compatibility
def get_ppid():