Skip to content

Instantly share code, notes, and snippets.

@pardo
Created September 11, 2015 15:35
Show Gist options
  • Save pardo/40b01d2db3a1e8f78762 to your computer and use it in GitHub Desktop.
Save pardo/40b01d2db3a1e8f78762 to your computer and use it in GitHub Desktop.
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
from django.core.exceptions import SuspiciousOperation
def skip_suspicious_operations(record):
if record.exc_info:
exc_value = record.exc_info[1]
if isinstance(exc_value, SuspiciousOperation):
return False
return True
LOGGING = {
'filters': {
'skip_suspicious_operations': {
'()': 'django.utils.log.CallbackFilter',
'callback': skip_suspicious_operations,
},
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['skip_suspicious_operations'],
'class': 'django.utils.log.AdminEmailHandler',
'include_html': True
},
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment