Error logging for DRF projects: log occuring errors, group them by endpoint, and reconstruct them without effort.
Catches all Exceptions except django.http.Http404 and rest_framework.exceptions.ValidationError, and logs them. You can then get the requests that caused errors: all, one per group or all not yet resolved ones.
- Clone this project into your Django project
- Add
logger
to your installed apps in setting.py - Add
logger.core.LoggingMiddleware
to your middleware in settings.py python manage.py migrate
You have an overview over all errors in the django admin site, and logger provides a view in its subpath /list
with overview over all errors.
You can define if you see all errors or only one (if possible, unresolved) error per group, by putting this into your settings:
LOGGER = {
"one_per_group": True
}
Not sure what the default behaviour is.
You can add one of these to your tests:
Call one of these in your tests to get errors
errors = logger.core.get_one_error_per_group()
errors = logger.core.get_all_errors()
errors = logger.core.get_all_unresolved()
And then
for error in errors:
succes, msg = logger.core.run_error(error)
...
- Requests with files: files are not saved
- Auto generate test cases