本文整理汇总了Python中logging.handlers.BufferingHandler.close方法的典型用法代码示例。如果您正苦于以下问题:Python BufferingHandler.close方法的具体用法?Python BufferingHandler.close怎么用?Python BufferingHandler.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logging.handlers.BufferingHandler
的用法示例。
在下文中一共展示了BufferingHandler.close方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: close
# 需要导入模块: from logging.handlers import BufferingHandler [as 别名]
# 或者: from logging.handlers.BufferingHandler import close [as 别名]
def close(self):
"""Upon `close`, flush our internal info to the target"""
# Flush our buffers to the target
# https://github.com/python/cpython/blob/3.3/Lib/logging/handlers.py#L1185
# https://github.com/python/cpython/blob/3.3/Lib/logging/handlers.py#L1241-L1256
self.acquire()
try:
for record in self.buffer:
if record.levelno < self.level:
continue
msg = self.format(record)
print(msg, file=self._fd_target)
finally:
self.release()
# Then, run our normal close actions
if issubclass(BufferingTargetHandler, object):
super(BufferingTargetHandler, self).close()
else:
BufferingHandler.close(self)