[Tutor] short url processor

ian douglas ian.douglas at iandouglas.com
Sat May 14 02:42:31 CEST 2011


On 05/13/2011 05:03 PM, Alan Gauld wrote:
> How do you know they are going to stdout? Are you sure
> they aren't going to stderr and stderrr is not mapped to stdout
> (usually the default). Have you tried redirecting stderr to a
> file for example?
>
> As I say, just some thoughts,
>

Thanks for your thoughts, Alan. I had done some testing with cmdline 
redirects and forget which is was, I think my debug log was going to 
stdout and the apache-style log was going to stderr, or the other way 
around...

After a handful of guys in the #python IRC channel very nearly convinced 
me that all but 3 stdlib libraries are utter worthless crap, and telling 
me to download and use third-party frameworks just to fix a simple 
logging issue, I overrode log_request() and log message() as such:

class clientThread(BaseHTTPRequestHandler): #[[[

         def log_request(code, size):
                 return

         def log_message(self, format, *args):
                 open(LOGFILE, "a").write("%s\n" % (format%args))


... and now the only logging going on is my own, and it's logged to my 
external file. Overriding log_request means that BaseHTTPServer no 
longer outputs its apache-style log, and overriding log_message means my 
other logging.info() and logging.debug() messages go out to my file as 
expected.

-id

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110513/b45aa5f8/attachment.html>


More information about the Tutor mailing list