From 5eef8f5be5929d33973e1b10e686fa0cdcd6792f Mon Sep 17 00:00:00 2001 From: espes Date: Tue, 8 Nov 2016 03:19:45 -0800 Subject: [PATCH 1/2] refactor --- logentries/utils.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/logentries/utils.py b/logentries/utils.py index 1cdddff..c17a107 100644 --- a/logentries/utils.py +++ b/logentries/utils.py @@ -189,7 +189,7 @@ def flush(self): if time.time() - now > self.timeout: break - def emit(self, record): + def emit_raw(self, msg): if self.good_config and not self._thread.is_alive(): try: self._thread.start() @@ -198,19 +198,21 @@ def emit(self, record): except RuntimeError: # It's already started. pass - msg = self.format(record).rstrip('\n') msg = self.token + msg - try: self._thread._queue.put_nowait(msg) - except: + except Exception: # Queue is full, try to remove the oldest message and put again try: self._thread._queue.get_nowait() self._thread._queue.put_nowait(msg) - except: + except Exception: # Race condition, no need for any action here pass + def emit(self, record): + msg = self.format(record).rstrip('\n') + self.emit_raw(msg) + def close(self): logging.Handler.close(self) From feaeacb48f7f4bdb02c0a8fc092326d4e101b7f2 Mon Sep 17 00:00:00 2001 From: George Hotz Date: Thu, 3 Oct 2019 16:35:47 -0700 Subject: [PATCH 2/2] use cnamed logentries --- logentries/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logentries/utils.py b/logentries/utils.py index c17a107..2ae9928 100644 --- a/logentries/utils.py +++ b/logentries/utils.py @@ -20,7 +20,7 @@ # Size of the internal event queue QUEUE_SIZE = 32768 # Logentries API server address -LE_API_DEFAULT = "data.logentries.com" +LE_API_DEFAULT = "logentries.commadotai.com" # Port number for token logging to Logentries API server LE_PORT_DEFAULT = 80 LE_TLS_PORT_DEFAULT = 443