def msg(self, *message, **kw): """ Log a new message. For example:: >>> log.msg('Hello, world.') In particular, you MUST avoid the forms:: >>> log.msg(u'Hello, world.') >>> log.msg('Hello ', 'world.') These forms work (sometimes) by accident and will be disabled entirely in the future. """ actualEventDict = (context.get(ILogContext) or {}).copy() actualEventDict.update(kw) actualEventDict['message'] = message actualEventDict['time'] = time.time() for i in xrange(len(self.observers) - 1, -1, -1): try: self.observers[i](actualEventDict) except KeyboardInterrupt: # Don't swallow keyboard interrupt! raise except UnicodeEncodeError: raise except: observer = self.observers[i] self.observers[i] = lambda event: None err(failure.Failure(), "Log observer %s failed." % (observer,)) self.observers[i] = observer
def callWithContext(ctx, func, *args, **kw): newCtx = context.get(ILogContext).copy() newCtx.update(ctx) return context.call({ILogContext: newCtx}, func, *args, **kw)