En Mon, 05 May 2008 00:33:12 -0300, skunkwerk <[EMAIL PROTECTED]> escribió:

> i'm redirecting the stdout & stderr of my python program to a log.
> Tests i've done on a simple program with print statements, etc. work
> fine.  however, in my actual program i get weird output like this:
>
> 2008-05-04 20:20:44,790 DEBUG Grabbing message from queue, if any
> 2008-05-04 20:20:44,790 DEBUG DEBUG:doit:Grabbing message from queue,
> if any
> 2008-05-04 20:20:44,790 DEBUG DEBUG:doit:DEBUG:doit:Grabbing message
> from queue, if any
> 2008-05-04 20:20:44,790 DEBUG
> DEBUG:doit:DEBUG:doit:DEBUG:doit:Grabbing message from queue, if any
>
>
> class write2Log:
>       def write(self, x):
>               if x!='\n':
>                       logger.debug(str(x))
>
> any ideas what might be causing the problems?  some of the messages
> being output are quite long - might this be a problem?

Try this simplified example and see by yourself:

import sys

class Write2Log:
     def write(self, x):
         sys.__stdout__.write('[%s]' % x)

sys.stdout = Write2Log()

print "Hello world!"
age = 27
name = "John"
print "My name is", name, "and I am", age, "years old."

-- 
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to