diff --git a/django/core/handlers/base.py b/django/core/handlers/base.py
index 3606e18..a0918bf 100644
a
|
b
|
class BaseHandler(object):
|
136 | 136 | response = response.render() |
137 | 137 | |
138 | 138 | except http.Http404, e: |
139 | | logger.warning('Not Found: %s' % request.path, |
| 139 | logger.warning('Not Found: %s', request.path, |
140 | 140 | extra={ |
141 | 141 | 'status_code': 404, |
142 | 142 | 'request': request |
… |
… |
class BaseHandler(object):
|
155 | 155 | signals.got_request_exception.send(sender=self.__class__, request=request) |
156 | 156 | except exceptions.PermissionDenied: |
157 | 157 | logger.warning( |
158 | | 'Forbidden (Permission denied): %s' % request.path, |
| 158 | 'Forbidden (Permission denied): %s', request.path, |
159 | 159 | extra={ |
160 | 160 | 'status_code': 403, |
161 | 161 | 'request': request |
… |
… |
class BaseHandler(object):
|
208 | 208 | if settings.DEBUG_PROPAGATE_EXCEPTIONS: |
209 | 209 | raise |
210 | 210 | |
211 | | logger.error('Internal Server Error: %s' % request.path, |
| 211 | logger.error('Internal Server Error: %s', request.path, |
212 | 212 | exc_info=exc_info, |
213 | 213 | extra={ |
214 | 214 | 'status_code': 500, |
diff --git a/django/db/backends/util.py b/django/db/backends/util.py
index b0463b7..9706268 100644
a
|
b
|
class CursorDebugWrapper(CursorWrapper):
|
42 | 42 | 'sql': sql, |
43 | 43 | 'time': "%.3f" % duration, |
44 | 44 | }) |
45 | | logger.debug('(%.3f) %s; args=%s' % (duration, sql, params), |
| 45 | logger.debug('(%.3f) %s; args=%s', duration, sql, params, |
46 | 46 | extra={'duration':duration, 'sql':sql, 'params':params} |
47 | 47 | ) |
48 | 48 | |
… |
… |
class CursorDebugWrapper(CursorWrapper):
|
57 | 57 | 'sql': '%s times: %s' % (len(param_list), sql), |
58 | 58 | 'time': "%.3f" % duration, |
59 | 59 | }) |
60 | | logger.debug('(%.3f) %s; args=%s' % (duration, sql, param_list), |
| 60 | logger.debug('(%.3f) %s; args=%s', duration, sql, param_list, |
61 | 61 | extra={'duration':duration, 'sql':sql, 'params':param_list} |
62 | 62 | ) |
63 | 63 | |
diff --git a/django/middleware/common.py b/django/middleware/common.py
index 4dd2e14..aaa094d 100644
a
|
b
|
class CommonMiddleware(object):
|
42 | 42 | if 'HTTP_USER_AGENT' in request.META: |
43 | 43 | for user_agent_regex in settings.DISALLOWED_USER_AGENTS: |
44 | 44 | if user_agent_regex.search(request.META['HTTP_USER_AGENT']): |
45 | | logger.warning('Forbidden (User agent): %s' % request.path, |
| 45 | logger.warning('Forbidden (User agent): %s', request.path, |
46 | 46 | extra={ |
47 | 47 | 'status_code': 403, |
48 | 48 | 'request': request |
diff --git a/django/middleware/csrf.py b/django/middleware/csrf.py
index 37f92b1..856c266 100644
a
|
b
|
class CsrfViewMiddleware(object):
|
134 | 134 | # we can use strict Referer checking. |
135 | 135 | referer = request.META.get('HTTP_REFERER') |
136 | 136 | if referer is None: |
137 | | logger.warning('Forbidden (%s): %s' % (REASON_NO_REFERER, request.path), |
| 137 | logger.warning('Forbidden (%s): %s', REASON_NO_REFERER, request.path, |
138 | 138 | extra={ |
139 | 139 | 'status_code': 403, |
140 | 140 | 'request': request, |
… |
… |
class CsrfViewMiddleware(object):
|
146 | 146 | good_referer = 'https://%s/' % request.get_host() |
147 | 147 | if not same_origin(referer, good_referer): |
148 | 148 | reason = REASON_BAD_REFERER % (referer, good_referer) |
149 | | logger.warning('Forbidden (%s): %s' % (reason, request.path), |
| 149 | logger.warning('Forbidden (%s): %s', reason, request.path, |
150 | 150 | extra={ |
151 | 151 | 'status_code': 403, |
152 | 152 | 'request': request, |
… |
… |
class CsrfViewMiddleware(object):
|
158 | 158 | # No CSRF cookie. For POST requests, we insist on a CSRF cookie, |
159 | 159 | # and in this way we can avoid all CSRF attacks, including login |
160 | 160 | # CSRF. |
161 | | logger.warning('Forbidden (%s): %s' % (REASON_NO_CSRF_COOKIE, request.path), |
| 161 | logger.warning('Forbidden (%s): %s', REASON_NO_CSRF_COOKIE, request.path, |
162 | 162 | extra={ |
163 | 163 | 'status_code': 403, |
164 | 164 | 'request': request, |
… |
… |
class CsrfViewMiddleware(object):
|
177 | 177 | request_csrf_token = request.META.get('HTTP_X_CSRFTOKEN', '') |
178 | 178 | |
179 | 179 | if not constant_time_compare(request_csrf_token, csrf_token): |
180 | | logger.warning('Forbidden (%s): %s' % (REASON_BAD_TOKEN, request.path), |
| 180 | logger.warning('Forbidden (%s): %s', REASON_BAD_TOKEN, request.path, |
181 | 181 | extra={ |
182 | 182 | 'status_code': 403, |
183 | 183 | 'request': request, |
diff --git a/django/views/decorators/http.py b/django/views/decorators/http.py
index 495a7b1..bf96371 100644
a
|
b
|
def require_http_methods(request_method_list):
|
31 | 31 | @wraps(func, assigned=available_attrs(func)) |
32 | 32 | def inner(request, *args, **kwargs): |
33 | 33 | if request.method not in request_method_list: |
34 | | logger.warning('Method Not Allowed (%s): %s' % (request.method, request.path), |
| 34 | logger.warning('Method Not Allowed (%s): %s', request.method, request.path, |
35 | 35 | extra={ |
36 | 36 | 'status_code': 405, |
37 | 37 | 'request': request |
… |
… |
def condition(etag_func=None, last_modified_func=None):
|
121 | 121 | if request.method in ("GET", "HEAD"): |
122 | 122 | response = HttpResponseNotModified() |
123 | 123 | else: |
124 | | logger.warning('Precondition Failed: %s' % request.path, |
| 124 | logger.warning('Precondition Failed: %s', request.path, |
125 | 125 | extra={ |
126 | 126 | 'status_code': 412, |
127 | 127 | 'request': request |
… |
… |
def condition(etag_func=None, last_modified_func=None):
|
130 | 130 | response = HttpResponse(status=412) |
131 | 131 | elif if_match and ((not res_etag and "*" in etags) or |
132 | 132 | (res_etag and res_etag not in etags)): |
133 | | logger.warning('Precondition Failed: %s' % request.path, |
| 133 | logger.warning('Precondition Failed: %s', request.path, |
134 | 134 | extra={ |
135 | 135 | 'status_code': 412, |
136 | 136 | 'request': request |
diff --git a/django/views/generic/base.py b/django/views/generic/base.py
index ea14281..556d0eb 100644
a
|
b
|
class View(object):
|
68 | 68 | |
69 | 69 | def http_method_not_allowed(self, request, *args, **kwargs): |
70 | 70 | allowed_methods = [m for m in self.http_method_names if hasattr(self, m)] |
71 | | logger.warning('Method Not Allowed (%s): %s' % (request.method, request.path), |
| 71 | logger.warning('Method Not Allowed (%s): %s', request.method, request.path, |
72 | 72 | extra={ |
73 | 73 | 'status_code': 405, |
74 | 74 | 'request': self.request |
… |
… |
class RedirectView(View):
|
157 | 157 | else: |
158 | 158 | return http.HttpResponseRedirect(url) |
159 | 159 | else: |
160 | | logger.warning('Gone: %s' % self.request.path, |
| 160 | logger.warning('Gone: %s', self.request.path, |
161 | 161 | extra={ |
162 | 162 | 'status_code': 410, |
163 | 163 | 'request': self.request |
diff --git a/django/views/generic/simple.py b/django/views/generic/simple.py
index c3cf407..110932a 100644
a
|
b
|
def redirect_to(request, url, permanent=True, query_string=False, **kwargs):
|
60 | 60 | klass = permanent and HttpResponsePermanentRedirect or HttpResponseRedirect |
61 | 61 | return klass(url) |
62 | 62 | else: |
63 | | logger.warning('Gone: %s' % request.path, |
| 63 | logger.warning('Gone: %s', request.path, |
64 | 64 | extra={ |
65 | 65 | 'status_code': 410, |
66 | 66 | 'request': request |
diff --git a/tests/regressiontests/views/views.py b/tests/regressiontests/views/views.py
index f2b4e79..1d17e6e 100644
a
|
b
|
def send_log(request, exc_info):
|
149 | 149 | ][0] |
150 | 150 | orig_filters = admin_email_handler.filters |
151 | 151 | admin_email_handler.filters = [] |
152 | | logger.error('Internal Server Error: %s' % request.path, |
| 152 | logger.error('Internal Server Error: %s', request.path, |
153 | 153 | exc_info=exc_info, |
154 | 154 | extra={ |
155 | 155 | 'status_code': 500, |