Skip to content

Commit 5eef8f5

Browse files
committed
refactor
1 parent c5c4044 commit 5eef8f5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

logentries/utils.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def flush(self):
189189
if time.time() - now > self.timeout:
190190
break
191191

192-
def emit(self, record):
192+
def emit_raw(self, msg):
193193
if self.good_config and not self._thread.is_alive():
194194
try:
195195
self._thread.start()
@@ -198,19 +198,21 @@ def emit(self, record):
198198
except RuntimeError: # It's already started.
199199
pass
200200

201-
msg = self.format(record).rstrip('\n')
202201
msg = self.token + msg
203-
204202
try:
205203
self._thread._queue.put_nowait(msg)
206-
except:
204+
except Exception:
207205
# Queue is full, try to remove the oldest message and put again
208206
try:
209207
self._thread._queue.get_nowait()
210208
self._thread._queue.put_nowait(msg)
211-
except:
209+
except Exception:
212210
# Race condition, no need for any action here
213211
pass
214212

213+
def emit(self, record):
214+
msg = self.format(record).rstrip('\n')
215+
self.emit_raw(msg)
216+
215217
def close(self):
216218
logging.Handler.close(self)

0 commit comments

Comments
 (0)