diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2010-10-04 15:12:39 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2010-10-04 15:12:39 +0000 |
| commit | 24acca413977422681ca16b42fe9a6d763df2121 (patch) | |
| tree | 0d3e1df0b023581725107984b5d6c57544bba7a0 /django/core/handlers/modpython.py | |
| parent | 667d832e901ca6bb394054109e24a2ed6cadc563 (diff) | |
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
Diffstat (limited to 'django/core/handlers/modpython.py')
| -rw-r--r-- | django/core/handlers/modpython.py | 12 |
1 files changed, 12 insertions, 0 deletions
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) |
