Why are assertions logged to sentries when DEBUG = True?
I am in the middle of deploying a clock device to handle django error messages. I have configured django options LOGGING
for registration only DEBUG = False
with 'filters': ['require_debug_false']
.
If I manually log the error in the django view like in the following example, it is successfully filtered and therefore not sent to the sentry:
import logging
logger = logging.getLogger(__name__)
def view_name(request):
logger.error('An error message')
...
However, if I use an operator assert
like in the following example, it is not filtered and sent to the hourly:
import logging
logger = logging.getLogger(__name__)
def view_name(request):
assert False, 'An error message'
...
It is also worth noting that the statement is assert
not sent to the handler mail_admins
, which also uses the same filter.
Can someone please help me to prevent errors assert
from starting to send to chat, yet DEBUG = True
?
Here are the versions of the packages I am using:
Django==1.6.7
raven==5.1.1
And here are the relevant parts of my .py settings:
DEBUG = True
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'formatters': {
'simple': {
'format': '%(levelname)s %(asctime)s %(message)s'
},
},
'handlers': {
'console': {
'level': 'WARNING',
'filters': ['require_debug_false'],
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler',
'include_html': True,
},
'sentry': {
'level': 'WARNING',
'filters': ['require_debug_false'],
'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
},
},
'loggers': {
'': {
'handlers': ['console', 'mail_admins', 'sentry'],
'level': 'WARNING',
'propagate': False,
},
},
}
source to share
In raven-python 3.0.0, DEBUG
setting in Django no longer disables Raven .
From the documentation :
Raven set a hook in Django that will automatically report uncaught exceptions
In your case, assert
throw an uncaught exceptions
AssertionError that logged into the Sentry system.
To disable this functionality, install dsn = None
or uninstall dsn ( source ):
RAVEN_CONFIG = {
'dsn': None
}
source to share