summaryrefslogtreecommitdiff
path: root/django/utils/cache.py
diff options
context:
space:
mode:
authorSamir Shah <solaris.smoke@gmail.com>2017-07-13 07:09:18 +0300
committerTim Graham <timograham@gmail.com>2018-05-04 20:55:03 -0400
commit10b44e45256ddda4258ae032b8d4725a3e3284e6 (patch)
treede7c8b159c5104d3da1a2b51a946d35404be07d6 /django/utils/cache.py
parent2e1f674897e89bbc69a389696773aebfec601916 (diff)
downloaddjango-10b44e45256ddda4258ae032b8d4725a3e3284e6.tar.gz
Fixed #26688 -- Fixed HTTP request logging inconsistencies.
* Added logging of 500 responses for instantiated responses. * Added logging of all 4xx and 5xx responses.
Diffstat (limited to 'django/utils/cache.py')
-rw-r--r--django/utils/cache.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/django/utils/cache.py b/django/utils/cache.py
index 7117d40526..0e0428fc11 100644
--- a/django/utils/cache.py
+++ b/django/utils/cache.py
@@ -17,7 +17,6 @@ An example: i18n middleware would need to distinguish caches by the
"Accept-language" header.
"""
import hashlib
-import logging
import re
import time
@@ -28,13 +27,12 @@ from django.utils.encoding import force_bytes, iri_to_uri
from django.utils.http import (
http_date, parse_etags, parse_http_date_safe, quote_etag,
)
+from django.utils.log import log_response
from django.utils.timezone import get_current_timezone_name
from django.utils.translation import get_language
cc_delim_re = re.compile(r'\s*,\s*')
-logger = logging.getLogger('django.request')
-
def patch_cache_control(response, **kwargs):
"""
@@ -106,14 +104,13 @@ def set_response_etag(response):
def _precondition_failed(request):
- logger.warning(
+ response = HttpResponse(status=412)
+ log_response(
'Precondition Failed: %s', request.path,
- extra={
- 'status_code': 412,
- 'request': request,
- },
+ response=response,
+ request=request,
)
- return HttpResponse(status=412)
+ return response
def _not_modified(request, response=None):