From 24acca413977422681ca16b42fe9a6d763df2121 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Mon, 4 Oct 2010 15:12:39 +0000 Subject: Fixed #12012 -- Added support for logging. Thanks to Vinay Sajip for his draft patch, and to the many people who gave feedback during development of the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@13981 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/handlers/modpython.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'django/core/handlers/modpython.py') diff --git a/django/core/handlers/modpython.py b/django/core/handlers/modpython.py index 17e739600c..395ec65314 100644 --- a/django/core/handlers/modpython.py +++ b/django/core/handlers/modpython.py @@ -1,5 +1,7 @@ +import logging import os from pprint import pformat +import sys from warnings import warn from django import http @@ -9,6 +11,9 @@ from django.core.urlresolvers import set_script_prefix from django.utils import datastructures from django.utils.encoding import force_unicode, smart_str, iri_to_uri +logger = logging.getLogger('django.request') + + # NOTE: do *not* import settings (or any module which eventually imports # settings) until after ModPythonHandler has been called; otherwise os.environ # won't be set up correctly (with respect to settings). @@ -200,6 +205,13 @@ class ModPythonHandler(BaseHandler): try: request = self.request_class(req) except UnicodeDecodeError: + logger.warning('Bad Request (UnicodeDecodeError): %s' % request.path, + exc_info=sys.exc_info(), + extra={ + 'status_code': 400, + 'request': request + } + ) response = http.HttpResponseBadRequest() else: response = self.get_response(request) -- cgit v1.3