[TransWarp] peak.running.logs

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


Phillip J. Eby wrote:
> Or, if the string is dynamic, then either:
> 
> self.logger.info(someVar.replace("%","%%"))
I think, that self.logger.info(someVar) looks better, than
self.logger.info(someVar.replace...) or
self.logger.info("%s", someVar)

why you can't test `args` parameter in 
peak.running.logs._levelledMessage? Implementation like:

def _levelledMessage(lvl,exc_info=()):

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

is not much slower (even could be faster), but in this case we could not 
take care of formating sequences in the message - if we have something 
to interpolate with, we will do it, if we have nothing, we will do nothing.

--
Best regards,
Yaroslav




More information about the PEAK mailing list