[TransWarp] peak.running.logs

Yaroslav Samchuk yarcat at ank-sia.com
Tue Aug 19 06:34:11 EDT 2003


The problem is while I'm trying to log something, containing "%" symbol 
in the message.


=== peak/running/logs.py:329 ===

def _levelledMessage(lvl,exc_info=()):

     def msg(self, msg, *args, **kwargs):
         if self.level <= lvl:
             self.publish(
                 self.EventClass(
!!!                 (msg % args), self, priority=lvl, **kwargs
                 )
             )
     return msg

======

look at the line, marked with "!!!". here we see a tuple (msg % args).

let's imagine, that logger was called like:
self.logger.info("log percent sign %")

due to that tuple we will have ("log percent sign %" % ()), that will 
raise an exception <<ValueError: incomplete format>>

the only way to avoid this exception is to call logger like:
self.logger.info("%s", "log percent sign %")

is it a bug or a feature?


--
Best regards,
Yaroslav




More information about the PEAK mailing list