示例#1
0
	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
示例#2
0
    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
示例#3
0
def callWithContext(ctx, func, *args, **kw):
	newCtx = context.get(ILogContext).copy()
	newCtx.update(ctx)
	return context.call({ILogContext: newCtx}, func, *args, **kw)
示例#4
0
def callWithContext(ctx, func, *args, **kw):
    newCtx = context.get(ILogContext).copy()
    newCtx.update(ctx)
    return context.call({ILogContext: newCtx}, func, *args, **kw)