diff --git a/logentries/utils.py b/logentries/utils.py index 1cdddff..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 @@ -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)