From a814167454826494306692e0764646134a01f393 Mon Sep 17 00:00:00 2001 From: enjoy-binbin Date: Sat, 24 Apr 2021 23:19:52 +0800 Subject: [PATCH] call handleError when emit raise exception --- fluent/handler.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/fluent/handler.py b/fluent/handler.py index 7aefd8f..d7dea03 100644 --- a/fluent/handler.py +++ b/fluent/handler.py @@ -229,13 +229,17 @@ def getSenderInstance(self, tag, host, port, timeout, verbose, nanosecond_precision=nanosecond_precision, **kwargs) def emit(self, record): - data = self.format(record) - _sender = self.sender - return _sender.emit_with_time(None, - sender.EventTime(record.created) - if _sender.nanosecond_precision - else int(record.created), - data) + try: + data = self.format(record) + _sender = self.sender + return _sender.emit_with_time(None, + sender.EventTime(record.created) + if _sender.nanosecond_precision + else int(record.created), + data) + except Exception as e: + self.handleError(record) + raise e def close(self): self.acquire()