[Zope] Catching the print

Dieter Maurer dieter@handshake.de
Thu, 23 Aug 2001 22:24:29 +0200 (CEST)


Peter Bengtsson writes:
 > In Linux I currently use the nohub program.
 > 
 > $ nohub ./start &
 > 
 > to start Zope.
 > That's good, and in nohub.out I get the messages Zope throws.
 > However, when I sometimes use
 > print "I am here"
 > 
 > in External Methods or products, that is also printed to stdout, but not
 > into the nohub.
 > Why??
It is printed into "nohup.out", but "nohup.out" is buffered.
You will see it only when the buffer is full or explicitely flushed.

Add:

	from sys import stdout
	stdout.flush()

after your print statement and you will see the output
immediately in "nohup.out".

 > How do I catch the print messages too?
 > And on windows?
Even Windows supports redirection of "stdout".
Apparently, it stole (and that has been good!) the Unix syntax: "> xxx".
We all like that our software incorporates good ideas from others,
don't we?


Dieter