In a development environment (DEBUG = True), django will display an error screen with a familiar and useful stack trace if an error occurs on the view.
However, in the case of a production environment, an email indicating that there was an error is sent to the email address set in ADMINS.
Also, if you are using slack_log_handler, the content of the error will be sent to slack.
I created django-malice because if something works after an error, I have to check it correctly.
--Provides a View to intentionally raise the following error
It also provides a page that returns HTTP 200 OK to check the normal system (HeartBeat, etc.).
django-malice (GitHub Repository)
――It is troublesome to prepare a View to raise an error intentionally to check the following. Then make and distribute. --I want to check if the error report is sent correctly --I want to check if the operation triggered by logging or error is driven correctly.
$ pip install django-malice
INSTALLED_APPS = [
...
"malice",
]
url(r'^malice/', include('malice.urls', namespace='malice')),
Note: In a production environment, it is safer to change the URL to a string that the attacker cannot predict.
Example:
view_urlpatterns = [
...
url(r'^all-your-error-are-belong-to-us-2101/', include('malice.urls', namespace='malice')),
...
]
$ ./manage.py runserver 0.0.0.0:8000
Make sure that URLs other than 200 return an error.
If DEBUG is True, no mail will be sent to ADMINS, so set the DEBUG flag to False and make sure that an error report is sent.
This application built tests on circleci, packaged it, and distributed it on Pypi throughout the django meetup time.
Thanks to BeProud's https://twitter.com/hirokiky and https://twitter.com/shimizukawa for hosting the event here!
If you have time, why don't you join django meetup!
Recommended Posts