ph87 / django-logging

Automatically exported from code.google.com/p/django-logging
0 stars 0 forks source link

Django-logging middleware should not intercept exception pages #16

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Configure django project setting with DEBUG=TRUE as well to use
django-logging as an installed middleware
2. Write code in any of the app view to produce any kind of Exception
3. Browse that view from your browser

What is the expected output? What do you see instead?
Expected output is the exception response generated by django framework,
but instead an simple python exception is returned simply as django-logging
middleware fails to parse the exception response generted by django.
According to me django-logging should not intercept and try to process the
default django exception responses as such pages have enough information
than the information that can be provided by custom logging to trace the
actual issue.

What version of the product are you using? On what operating system?
I'm using r25 from svn checkout in windows with pinax (django-hotclub)
application suite.

Please provide any additional information below.

Below is a sample browser response generated by django-logging middleware
while processing an exception response generated by django framework.

Traceback (most recent call last):

  File "C:\Soft\Dev_soft\Libs\Python\Django\svn\django\core\servers
\basehttp.py", line 277, in run
    self.result = application(self.environ, self.start_response)

  File "C:\Soft\Dev_soft\Libs\Python\Django\svn\django\core\servers
\basehttp.py", line 634, in __call__
    return self.application(environ, start_response)

  File "C:\Soft\Dev_soft\Libs\Python\Django\svn\django\core\handlers
\wsgi.py", line 220, in __call__
    response = middleware_method(request, response)

  File "C:\Soft\Dev_soft\Libs\Python\Django\apps\django-hotclub\trunk
\apps\djangologging\middleware.py", line 153, in process_response
    self._rewrite_html(request, response)

  File "C:\Soft\Dev_soft\Libs\Python\Django\apps\django-hotclub\trunk
\apps\djangologging\middleware.py", line 187, in _rewrite_html
    response.content = close_body_re.sub(r'%s\1' % footer,
response.content)

  File "C:\Python25\Lib\re.py", line 269, in _subx
    template = _compile_repl(template, pattern)

  File "C:\Python25\Lib\re.py", line 256, in _compile_repl
    raise error, v # invalid expression

error: bad group name 

Original issue reported on code.google.com by mnis4...@gmail.com on 16 Aug 2008 at 3:48

GoogleCodeExporter commented 9 years ago
Hi,

To work around the above issue in my development environment I've modified the
management.py file and the patch file is attached herewith. Basically its a one 
line
fix in the process_response method.

Please fell free to ignore/improve my modifications as per your understanding 
of side
effects, but it is working smooth for me.

Regards,
Shihan

Original comment by mnis4...@gmail.com on 20 Aug 2008 at 3:19

Attachments:

GoogleCodeExporter commented 9 years ago
Hi Shihan,

Displaying the log message in an error response should work fine, and has for 
me on
many occasions. The traceback you provided helped me to identify an issue in 
the way
the the log is injected into the HTML.

If the document content contains anything that looks like a regular expression 
back
reference (\1, \2, \3, etc.) then the error you described would occur.

This has been fixed in r26.

Would you be able to update and test whether this has fixed the problem in your
environment?

Thanks,

Fraser

Original comment by fras...@gmail.com on 21 Aug 2008 at 8:00

GoogleCodeExporter commented 9 years ago
Hi Fraser,

I've updated my working copy for django-logging to r26 and yes, this issue now 
seemed
to be fixed and the Log is currently displayed properly even in the exception 
pages.

I'll let you know if I find any other inconsistencies (along with this as well) 
my
future use of django-logging application.

Actually as django-logging is basically a helper app to operate in middle, any
exception within it becomes very frustrating and misleading to the newbies like 
me
while trying to install and run another project (pinax was my case) that has
dependencies to it.

Thank you very much for the quick update.
Regards,
Shihan

Original comment by mnis4...@gmail.com on 21 Aug 2008 at 12:51

GoogleCodeExporter commented 9 years ago
Marking as fixed.

Original comment by fras...@gmail.com on 21 Aug 2008 at 1:02