4 messages in com.googlegroups.pylons-discussTransLogger not helpful with errors| From | Sent On | Attachments |
|---|---|---|
| Mike Orr | 14 Feb 2007 18:58 | |
| Ian Bicking | 14 Feb 2007 19:19 | |
| Mike Orr | 15 Feb 2007 12:17 | .txt |
| Mike Orr | 20 Feb 2007 15:20 |
| Subject: | TransLogger not helpful with errors![]() |
|---|---|
| From: | Mike Orr (slug...@public.gmane.org) |
| Date: | 02/14/2007 06:58:31 PM |
| List: | com.googlegroups.pylons-discuss |
I enabled paste.translogger.TransLogger to get a summary of transactions on the console, and it shows Not Found errors like this:
=== 127.0.0.1 - - [14/Feb/2007:18:49:47 -0700] "GET /error/document/?message=Not+Found&code=404 HTTP/1.1" 200 - "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.1) Gecko/20061208 Firefox/2.0.0.1" 127.0.0.1 - - [14/Feb/2007:18:49:47 -0700] "GET /error/style/orange.css HTTP/1.1" 304 - "http://localhost:5000/foo" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.1) Gecko/20061208 Firefox/2.0.0.1" 127.0.0.1 - - [14/Feb/2007:18:49:47 -0700] "GET /error/img/bg.jpg HTTP/1.1" 304 - "http://localhost:5000/error/style/orange.css" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.1) Gecko/20061208 Firefox/2.0.0.1" 127.0.0.1 - - [14/Feb/2007:18:49:47 -0700] "GET /error/img/logo.gif HTTP/1.1" 304 - "http://localhost:5000/foo" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.1) Gecko/20061208 Firefox/2.0.0.1" 127.0.0.1 - - [14/Feb/2007:18:49:48 -0700] "GET /error/img/tab-white.png HTTP/1.1" 304 - "http://localhost:5000/error/style/orange.css" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.1) Gecko/20061208 Firefox/2.0.0.1" 127.0.0.1 - - [14/Feb/2007:18:49:48 -0700] "GET /error/img/bar-bg.png HTTP/1.1" 304 - "http://localhost:5000/error/style/orange.css" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.1) Gecko/20061208 Firefox/2.0.0.1" ===
I'd like it to show the original request with its proper URL and status (404 or 500), but instead Pylons is doing some kind of internal redirect and swallowing the original error.
I made a subclass that suppresses the image/stylesheet requests, but it suppresses the erroneous request too:
=== from paste.translogger import TransLogger as _TransLogger
class TransLogger(_TransLogger): def __init__(self, application, **kw): self.ignore_url_prefixes = kw.pop("ignore_url_prefixes", []) _TransLogger.__init__(self, application, **kw)
def write_log(self, environ, *args, **kw): for prefix in self.ignore_url_prefixes: if environ.get("PATH_INFO", "").startswith(prefix): return _TransLogger.write_log(self, environ, *args, **kw) ===
app = TransLogger(app, setup_console_handler=True, ignore_url_prefixes=["/error"])
I do need to make my own logger because I'll be logging to CSV files, but I'd like to see Pylons have a useful transaction logger out of the box.
-- Mike Orr <slug...@public.gmane.org>





.txt