def close(self): """ Flush, set the target to None and lose the buffer. """ try: self.flush() finally: self.acquire() try: BufferingHandler.close(self) finally: self.release()
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)
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)