Created
September 11, 2015 15:35
-
-
Save pardo/40b01d2db3a1e8f78762 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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