diff --git a/logtail/frame.py b/logtail/frame.py index c4a168e..90fe89d 100644 --- a/logtail/frame.py +++ b/logtail/frame.py @@ -1,6 +1,6 @@ # coding: utf-8 from __future__ import print_function, unicode_literals -from datetime import datetime +from datetime import datetime, timezone from os import path import __main__ @@ -11,10 +11,8 @@ def create_frame(record, message, context, include_extra_attributes=False): if "request" in r and not isinstance(r["request"], (dict, list, bool, int, float, str)) : del r["request"] frame = {} - # Python 3 only solution if we ever drop Python 2.7 - # frame['dt'] = datetime.utcfromtimestamp(r['created']).replace(tzinfo=timezone.utc).isoformat() - frame['dt'] = "{}+00:00".format(datetime.utcfromtimestamp(r['created']).isoformat()) - frame['level'] = level = _levelname(r['levelname']) + frame['dt'] = datetime.fromtimestamp(r['created'], timezone.utc).isoformat() + frame['level'] = _levelname(r['levelname']) frame['severity'] = int(r['levelno'] / 10) frame['message'] = message frame['context'] = ctx = {} @@ -47,7 +45,7 @@ def _parse_custom_events(record, include_extra_attributes): default_keys = { 'args', 'asctime', 'created', 'exc_info', 'exc_text', 'pathname', 'funcName', 'levelname', 'levelno', 'lineno', 'module', 'msecs', - 'message', 'msg', 'name', 'pathname', 'process', 'processName', + 'message', 'msg', 'name', 'process', 'processName', 'relativeCreated', 'thread', 'threadName' } events = {} diff --git a/logtail/handler.py b/logtail/handler.py index f76ebfa..89946c9 100644 --- a/logtail/handler.py +++ b/logtail/handler.py @@ -68,7 +68,6 @@ def emit(self, record): # Only raised when not blocking, which means that extra events # should be dropped. self.dropcount += 1 - pass except Exception as e: if self.raise_exceptions: raise e diff --git a/tests/test_flusher.py b/tests/test_flusher.py index 32130b3..bfb3ce6 100644 --- a/tests/test_flusher.py +++ b/tests/test_flusher.py @@ -25,12 +25,11 @@ def _setup_worker(self, uploader=None): return pipe, uploader, fw def test_is_thread(self): - pipe, uploader, fw = self._setup_worker() + _, _, fw = self._setup_worker() self.assertIsInstance(fw, threading.Thread) def test_flushes_when_queue_is_full(self): first_frame = list(range(self.buffer_capacity)) - second_frame = list(range(self.buffer_capacity, self.buffer_capacity * 2)) self.calls = 0 self.flush_interval = 1000