From 057fdbc6d70d10d520a989101557b7d71a955440 Mon Sep 17 00:00:00 2001 From: John Watson Date: Wed, 8 Sep 2010 11:29:57 -0700 Subject: [PATCH] Add SENTRY_TESTING to settings.py so the exception can be tested with DEBUG enabled --- README.rst | 10 ++++++++++ sentry/client/models.py | 3 +-- sentry/settings.py | 6 +++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index b0e404e160d09b..0965e26e9b2bde 100644 --- a/README.rst +++ b/README.rst @@ -157,6 +157,16 @@ You can also use the ``exc_info`` and ``extra=dict(url=foo)`` arguments on your logging.error('There was some crazy error', exc_info=sys.exc_info(), extra={'url': request.build_absolute_uri()}) +############## +SENTRY_TESTING +############## + +Enabling this setting allows the testing of Sentry exception handler even if Django DEBUG is enabled. + +Default value is ``False`` + +.. note:: Normally when Django DEBUG is enabled the Sentry exception handler is immediately skipped + ===== Usage ===== diff --git a/sentry/client/models.py b/sentry/client/models.py index 71c9f89a8706e3..146f198f957a79 100644 --- a/sentry/client/models.py +++ b/sentry/client/models.py @@ -3,7 +3,6 @@ import logging import warnings -from django.conf import settings as dj_settings from django.core.signals import got_request_exception from django.db import transaction from django.http import Http404 @@ -23,7 +22,7 @@ def sentry_exception_handler(sender, request=None, **kwargs): and issubclass(exc_type, Http404): return - if dj_settings.DEBUG or getattr(exc_type, 'skip_sentry', False): + if settings.DEBUG or getattr(exc_type, 'skip_sentry', False): return if transaction.is_dirty(): diff --git a/sentry/settings.py b/sentry/settings.py index 325c23f89af11e..9a9025b2130dd5 100644 --- a/sentry/settings.py +++ b/sentry/settings.py @@ -4,6 +4,9 @@ import logging +# Allow local testing of Sentry even if DEBUG is enabled +DEBUG = getattr(settings, 'DEBUG', False) and not getattr(settings, 'SENTRY_TESTING', False) + CATCH_404_ERRORS = getattr(settings, 'SENTRY_CATCH_404_ERRORS', False) DATABASE_USING = getattr(settings, 'SENTRY_DATABASE_USING', None) @@ -33,4 +36,5 @@ # This should be the full URL to sentries store view REMOTE_URL = getattr(settings, 'SENTRY_REMOTE_URL', None) -REMOTE_TIMEOUT = getattr(settings, 'SENTRY_REMOTE_TIMEOUT', 5) \ No newline at end of file +REMOTE_TIMEOUT = getattr(settings, 'SENTRY_REMOTE_TIMEOUT', 5) +