Fixed #17358 -- Updated logging calls to use official syntax for arguments instead of string interpolation. Thanks, spulec.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17480 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
c609b792f7
commit
f0a1633425
|
@ -136,7 +136,7 @@ class BaseHandler(object):
|
||||||
response = response.render()
|
response = response.render()
|
||||||
|
|
||||||
except http.Http404, e:
|
except http.Http404, e:
|
||||||
logger.warning('Not Found: %s' % request.path,
|
logger.warning('Not Found: %s', request.path,
|
||||||
extra={
|
extra={
|
||||||
'status_code': 404,
|
'status_code': 404,
|
||||||
'request': request
|
'request': request
|
||||||
|
@ -155,7 +155,7 @@ class BaseHandler(object):
|
||||||
signals.got_request_exception.send(sender=self.__class__, request=request)
|
signals.got_request_exception.send(sender=self.__class__, request=request)
|
||||||
except exceptions.PermissionDenied:
|
except exceptions.PermissionDenied:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
'Forbidden (Permission denied): %s' % request.path,
|
'Forbidden (Permission denied): %s', request.path,
|
||||||
extra={
|
extra={
|
||||||
'status_code': 403,
|
'status_code': 403,
|
||||||
'request': request
|
'request': request
|
||||||
|
@ -208,7 +208,7 @@ class BaseHandler(object):
|
||||||
if settings.DEBUG_PROPAGATE_EXCEPTIONS:
|
if settings.DEBUG_PROPAGATE_EXCEPTIONS:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
logger.error('Internal Server Error: %s' % request.path,
|
logger.error('Internal Server Error: %s', request.path,
|
||||||
exc_info=exc_info,
|
exc_info=exc_info,
|
||||||
extra={
|
extra={
|
||||||
'status_code': 500,
|
'status_code': 500,
|
||||||
|
|
|
@ -42,7 +42,7 @@ class CommonMiddleware(object):
|
||||||
if 'HTTP_USER_AGENT' in request.META:
|
if 'HTTP_USER_AGENT' in request.META:
|
||||||
for user_agent_regex in settings.DISALLOWED_USER_AGENTS:
|
for user_agent_regex in settings.DISALLOWED_USER_AGENTS:
|
||||||
if user_agent_regex.search(request.META['HTTP_USER_AGENT']):
|
if user_agent_regex.search(request.META['HTTP_USER_AGENT']):
|
||||||
logger.warning('Forbidden (User agent): %s' % request.path,
|
logger.warning('Forbidden (User agent): %s', request.path,
|
||||||
extra={
|
extra={
|
||||||
'status_code': 403,
|
'status_code': 403,
|
||||||
'request': request
|
'request': request
|
||||||
|
|
|
@ -134,7 +134,7 @@ class CsrfViewMiddleware(object):
|
||||||
# we can use strict Referer checking.
|
# we can use strict Referer checking.
|
||||||
referer = request.META.get('HTTP_REFERER')
|
referer = request.META.get('HTTP_REFERER')
|
||||||
if referer is None:
|
if referer is None:
|
||||||
logger.warning('Forbidden (%s): %s' % (REASON_NO_REFERER, request.path),
|
logger.warning('Forbidden (%s): %s', REASON_NO_REFERER, request.path,
|
||||||
extra={
|
extra={
|
||||||
'status_code': 403,
|
'status_code': 403,
|
||||||
'request': request,
|
'request': request,
|
||||||
|
@ -146,7 +146,7 @@ class CsrfViewMiddleware(object):
|
||||||
good_referer = 'https://%s/' % request.get_host()
|
good_referer = 'https://%s/' % request.get_host()
|
||||||
if not same_origin(referer, good_referer):
|
if not same_origin(referer, good_referer):
|
||||||
reason = REASON_BAD_REFERER % (referer, good_referer)
|
reason = REASON_BAD_REFERER % (referer, good_referer)
|
||||||
logger.warning('Forbidden (%s): %s' % (reason, request.path),
|
logger.warning('Forbidden (%s): %s', reason, request.path,
|
||||||
extra={
|
extra={
|
||||||
'status_code': 403,
|
'status_code': 403,
|
||||||
'request': request,
|
'request': request,
|
||||||
|
@ -158,7 +158,7 @@ class CsrfViewMiddleware(object):
|
||||||
# No CSRF cookie. For POST requests, we insist on a CSRF cookie,
|
# No CSRF cookie. For POST requests, we insist on a CSRF cookie,
|
||||||
# and in this way we can avoid all CSRF attacks, including login
|
# and in this way we can avoid all CSRF attacks, including login
|
||||||
# CSRF.
|
# CSRF.
|
||||||
logger.warning('Forbidden (%s): %s' % (REASON_NO_CSRF_COOKIE, request.path),
|
logger.warning('Forbidden (%s): %s', REASON_NO_CSRF_COOKIE, request.path,
|
||||||
extra={
|
extra={
|
||||||
'status_code': 403,
|
'status_code': 403,
|
||||||
'request': request,
|
'request': request,
|
||||||
|
@ -177,7 +177,7 @@ class CsrfViewMiddleware(object):
|
||||||
request_csrf_token = request.META.get('HTTP_X_CSRFTOKEN', '')
|
request_csrf_token = request.META.get('HTTP_X_CSRFTOKEN', '')
|
||||||
|
|
||||||
if not constant_time_compare(request_csrf_token, csrf_token):
|
if not constant_time_compare(request_csrf_token, csrf_token):
|
||||||
logger.warning('Forbidden (%s): %s' % (REASON_BAD_TOKEN, request.path),
|
logger.warning('Forbidden (%s): %s', REASON_BAD_TOKEN, request.path,
|
||||||
extra={
|
extra={
|
||||||
'status_code': 403,
|
'status_code': 403,
|
||||||
'request': request,
|
'request': request,
|
||||||
|
|
|
@ -31,7 +31,7 @@ def require_http_methods(request_method_list):
|
||||||
@wraps(func, assigned=available_attrs(func))
|
@wraps(func, assigned=available_attrs(func))
|
||||||
def inner(request, *args, **kwargs):
|
def inner(request, *args, **kwargs):
|
||||||
if request.method not in request_method_list:
|
if request.method not in request_method_list:
|
||||||
logger.warning('Method Not Allowed (%s): %s' % (request.method, request.path),
|
logger.warning('Method Not Allowed (%s): %s', request.method, request.path,
|
||||||
extra={
|
extra={
|
||||||
'status_code': 405,
|
'status_code': 405,
|
||||||
'request': request
|
'request': request
|
||||||
|
@ -122,7 +122,7 @@ def condition(etag_func=None, last_modified_func=None):
|
||||||
if request.method in ("GET", "HEAD"):
|
if request.method in ("GET", "HEAD"):
|
||||||
response = HttpResponseNotModified()
|
response = HttpResponseNotModified()
|
||||||
else:
|
else:
|
||||||
logger.warning('Precondition Failed: %s' % request.path,
|
logger.warning('Precondition Failed: %s', request.path,
|
||||||
extra={
|
extra={
|
||||||
'status_code': 412,
|
'status_code': 412,
|
||||||
'request': request
|
'request': request
|
||||||
|
@ -131,7 +131,7 @@ def condition(etag_func=None, last_modified_func=None):
|
||||||
response = HttpResponse(status=412)
|
response = HttpResponse(status=412)
|
||||||
elif if_match and ((not res_etag and "*" in etags) or
|
elif if_match and ((not res_etag and "*" in etags) or
|
||||||
(res_etag and res_etag not in etags)):
|
(res_etag and res_etag not in etags)):
|
||||||
logger.warning('Precondition Failed: %s' % request.path,
|
logger.warning('Precondition Failed: %s', request.path,
|
||||||
extra={
|
extra={
|
||||||
'status_code': 412,
|
'status_code': 412,
|
||||||
'request': request
|
'request': request
|
||||||
|
|
|
@ -68,7 +68,7 @@ class View(object):
|
||||||
|
|
||||||
def http_method_not_allowed(self, request, *args, **kwargs):
|
def http_method_not_allowed(self, request, *args, **kwargs):
|
||||||
allowed_methods = [m for m in self.http_method_names if hasattr(self, m)]
|
allowed_methods = [m for m in self.http_method_names if hasattr(self, m)]
|
||||||
logger.warning('Method Not Allowed (%s): %s' % (request.method, request.path),
|
logger.warning('Method Not Allowed (%s): %s', request.method, request.path,
|
||||||
extra={
|
extra={
|
||||||
'status_code': 405,
|
'status_code': 405,
|
||||||
'request': self.request
|
'request': self.request
|
||||||
|
@ -157,7 +157,7 @@ class RedirectView(View):
|
||||||
else:
|
else:
|
||||||
return http.HttpResponseRedirect(url)
|
return http.HttpResponseRedirect(url)
|
||||||
else:
|
else:
|
||||||
logger.warning('Gone: %s' % self.request.path,
|
logger.warning('Gone: %s', self.request.path,
|
||||||
extra={
|
extra={
|
||||||
'status_code': 410,
|
'status_code': 410,
|
||||||
'request': self.request
|
'request': self.request
|
||||||
|
|
|
@ -60,7 +60,7 @@ def redirect_to(request, url, permanent=True, query_string=False, **kwargs):
|
||||||
klass = permanent and HttpResponsePermanentRedirect or HttpResponseRedirect
|
klass = permanent and HttpResponsePermanentRedirect or HttpResponseRedirect
|
||||||
return klass(url)
|
return klass(url)
|
||||||
else:
|
else:
|
||||||
logger.warning('Gone: %s' % request.path,
|
logger.warning('Gone: %s', request.path,
|
||||||
extra={
|
extra={
|
||||||
'status_code': 410,
|
'status_code': 410,
|
||||||
'request': request
|
'request': request
|
||||||
|
|
|
@ -149,7 +149,7 @@ def send_log(request, exc_info):
|
||||||
][0]
|
][0]
|
||||||
orig_filters = admin_email_handler.filters
|
orig_filters = admin_email_handler.filters
|
||||||
admin_email_handler.filters = []
|
admin_email_handler.filters = []
|
||||||
logger.error('Internal Server Error: %s' % request.path,
|
logger.error('Internal Server Error: %s', request.path,
|
||||||
exc_info=exc_info,
|
exc_info=exc_info,
|
||||||
extra={
|
extra={
|
||||||
'status_code': 500,
|
'status_code': 500,
|
||||||
|
|
Loading…
Reference in New Issue