On May 4, 10:40 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> 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

thanks Gabriel,
   i tried the code you sent and got output like the following:
[My name is][][john][][and I am][][27][][years old.]

it doesn't really help me though.  does this have any advantages over
the syntax i was using?
are there any limits on what kind of objects the logger can write?  ie
ascii strings of any length?

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

Reply via email to