[py-dev] Unicode support in py.log

holger krekel hpk at trillke.net
Wed Jul 13 17:19:10 CEST 2005


Hi Grig! 

On Wed, Jul 13, 2005 at 08:11 -0700, Grig Gheorghiu wrote:
> I was using the default STDOUT consumer in py.log when I ran into a
> problem printing strings that contain non-ASCII characters. I think we
> should modify at a minimum the 'content' method of the Message class in
> producer.py so that it uses unicode as opposed to str. Here's what I
> did temporarily to get past my problem:
> 
> def content(self):
>     return " ".join(map(unicode, self.args)).encode('utf-8')
>
> Of course, the encoding should be configurable, but I'm not sure if
> it's best to have it as a global variable in producer.py or some other
> way.

Hum, i am not sure about the best way to go about unicode handling in 
py.log context.  I guess that content() should always return 
a unicode object and the log consumer should care about encodings. 
And the default STDOUT/STDERR consumer should convert to the system 
encoding.  If a user wants something different he has to register
an appropriate consumer.  makes sense? 

    holger


More information about the py-dev mailing list