本文整理汇总了Python中logbook.base.LogRecord类的典型用法代码示例。如果您正苦于以下问题:Python LogRecord类的具体用法?Python LogRecord怎么用?Python LogRecord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LogRecord类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: log
def log(self, tags, msg, *args, **kwargs):
if isinstance(tags, basestring):
tags = [tags]
exc_info = kwargs.pop('exc_info', None)
extra = kwargs.pop('extra', {})
extra['tags'] = list(tags)
record = LogRecord(self.name, NOTSET, msg, args, kwargs, exc_info,
extra, sys._getframe(), self)
try:
self.handle(record)
finally:
record.close()
示例2: recv
def recv(self, timeout=None):
if timeout is None:
rv = self.queue.get()
else:
try:
rv = self.queue.get(block=False, timeout=timeout)
except Empty:
return None
return LogRecord.from_dict(rv)
示例3: recv
def recv(self, timeout=None):
"""Receives a single record from the socket. Timeout of 0 means nonblocking,
`None` means blocking and otherwise it's a timeout in seconds after which
the function just returns with `None`.
"""
if timeout is None:
rv = self.socket.recv()
elif not timeout:
rv = self.socket.recv(self._zmq.NOBLOCK)
if rv is None:
return
else:
if not self._zmq.select([self.socket], [], [], timeout)[0]:
return
rv = self.socket.recv(self._zmq.NOBLOCK)
return LogRecord.from_dict(json.loads(rv))
示例4: recv
def recv(self, timeout=None):
"""Overwrite standard recv for timeout calls to catch interrupt errors.
"""
if timeout:
try:
testsock = self._zmq.select([self.socket], [], [], timeout)[0]
except zmq.ZMQError as e:
if e.errno == errno.EINTR:
testsock = None
else:
raise
if not testsock:
return
rv = self.socket.recv(self._zmq.NOBLOCK)
return LogRecord.from_dict(json.loads(rv))
else:
return super(ZeroMQPullSubscriber, self).recv(timeout)