From cc31353d250c2a4a432a981cf7bc6bf75432e16b Mon Sep 17 00:00:00 2001 From: Oren Mazor Date: Wed, 31 Jan 2018 06:49:58 -0500 Subject: [PATCH] fix semantics I rushed through the first time. the handler shouldn't call a private method on the sender --- logzio/handler.py | 2 +- logzio/sender.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/logzio/handler.py b/logzio/handler.py index 60a90c9..71f55f8 100644 --- a/logzio/handler.py +++ b/logzio/handler.py @@ -46,7 +46,7 @@ class LogzioHandler(logging.Handler): return extra_fields def flush(self): - self.logzio_sender._flush_the_queue() + self.logzio_sender.flush() def format(self, record): message = super(LogzioHandler, self).format(record) diff --git a/logzio/sender.py b/logzio/sender.py index d16a3c6..7975f63 100644 --- a/logzio/sender.py +++ b/logzio/sender.py @@ -44,6 +44,9 @@ class LogzioSender: # Queue lib is thread safe, no issue here self.queue.put(json.dumps(logs_message)) + def flush(self): + self._flush_queue() + def _debug(self, message): if self.debug: print(str(message)) @@ -58,7 +61,7 @@ class LogzioSender: last_try = True try: - self._flush_the_queue() + self._flush_queue() except Exception as e: self._debug("Unexpected exception while draining queue to Logz.io, swallowing. Exception: " + str(e)) @@ -66,7 +69,7 @@ class LogzioSender: if not last_try: sleep(self.logs_drain_timeout) - def _flush_the_queue(self): + def _flush_queue(self): # Sending logs until queue is empty while not self.queue.empty(): logs_list = self._get_messages_up_to_max_allowed_size()