|
@ -34,7 +34,9 @@ class LogzioSender: |
|
|
|
|
|
|
|
|
# Create a queue to hold logs |
|
|
# Create a queue to hold logs |
|
|
self.queue = queue.Queue() |
|
|
self.queue = queue.Queue() |
|
|
|
|
|
self._initialize_sending_thread() |
|
|
|
|
|
|
|
|
|
|
|
def _initialize_sending_thread(self): |
|
|
self.sending_thread = Thread(target=self._drain_queue) |
|
|
self.sending_thread = Thread(target=self._drain_queue) |
|
|
self.sending_thread.daemon = False |
|
|
self.sending_thread.daemon = False |
|
|
self.sending_thread.name = "logzio-sending-thread" |
|
|
self.sending_thread.name = "logzio-sending-thread" |
|
@ -42,6 +44,8 @@ class LogzioSender: |
|
|
|
|
|
|
|
|
def append(self, logs_message): |
|
|
def append(self, logs_message): |
|
|
# Queue lib is thread safe, no issue here |
|
|
# Queue lib is thread safe, no issue here |
|
|
|
|
|
if not self.sending_thread.is_alive(): |
|
|
|
|
|
self._initialize_sending_thread() |
|
|
self.queue.put(json.dumps(logs_message)) |
|
|
self.queue.put(json.dumps(logs_message)) |
|
|
|
|
|
|
|
|
def flush(self): |
|
|
def flush(self): |
|
|