Browse Source

fix semantics I rushed through the first time. the handler shouldn't call a private method on the sender

opensearch
Oren Mazor 7 years ago
parent
commit
cc31353d25
2 changed files with 6 additions and 3 deletions
  1. +1
    -1
      logzio/handler.py
  2. +5
    -2
      logzio/sender.py

+ 1
- 1
logzio/handler.py View File

@ -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)


+ 5
- 2
logzio/sender.py View File

@ -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()


Loading…
Cancel
Save