On Mon, 5 Sep 2005, Martin Blais wrote:
> However, there is an easy way out: hijack sys.stdout to forward to
> your logger system.
> I've got a web application framework that's setup like that right now,
> it works great (if you will not need the original print-to-stdout
> anymore in your program, that is).  I print, it goes to the logfile. 
> You just have to be careful where--in time-- you replace sys.stdout.

Sure, and indeed I've done that often enough but it's kind of ugly and 
doesn't help if you merge bodies of code where some stuff should go to 
a log, some to stdout, some elsewhere.

Hmm, maybe I'd end up avoiding the builtin print() as well, or at 
least need to pass around the stream where I want output.  The general 
problem of not tying code to a particular output stream is what I'm 
reacting to.

- Stephan

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to