From f14c580266f4ea5f347a6db18ac3399dfd5e583d Mon Sep 17 00:00:00 2001 From: Roi Rav-Hon Date: Wed, 9 May 2018 20:46:58 +0300 Subject: [PATCH 1/4] Treat exception and non-exception the same --- README.md | 1 + logzio/handler.py | 11 ++++++----- setup.py | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b8d33ac..3b28f70 100644 --- a/README.md +++ b/README.md @@ -147,6 +147,7 @@ LOGGING = { - appname - Your django app ## Release Notes +- 2.0.10 - Not ignoring formatting on exceptions - 2.0.9 - Support extra fields on exceptions too (Thanks @asafc64!) - 2.0.8 - Various PEP8, testings and logging changes (Thanks @nir0s!) - 2.0.7 - Make sure sending thread is alive after fork (Thanks @jo-tham!) diff --git a/logzio/handler.py b/logzio/handler.py index f020453..1be38d4 100644 --- a/logzio/handler.py +++ b/logzio/handler.py @@ -86,12 +86,13 @@ class LogzioHandler(logging.Handler): if message.exc_info: return_json['exception'] = self.format_exception(message.exc_info) + message.exc_info = None # We want to ignore logging format on exceptions, as we handle those differently + + formatted_message = self.format(message) + if isinstance(formatted_message, dict): + return_json.update(formatted_message) else: - formatted_message = self.format(message) - if isinstance(formatted_message, dict): - return_json.update(formatted_message) - else: - return_json['message'] = formatted_message + return_json['message'] = formatted_message return_json.update(self.extra_fields(message)) return return_json diff --git a/setup.py b/setup.py index f07b898..4cd2244 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup, find_packages setup( name="logzio-python-handler", - version='2.0.9', + version='2.0.10', description="Logging handler to send logs to your Logz.io account with bulk SSL", keywords="logging handler logz.io bulk https", author="roiravhon", From d3ee46e88cc7e72117eff6f8f41d60237ec20330 Mon Sep 17 00:00:00 2001 From: Roi Rav-Hon Date: Wed, 9 May 2018 20:52:14 +0300 Subject: [PATCH 2/4] pep8 --- logzio/handler.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/logzio/handler.py b/logzio/handler.py index 1be38d4..59840f2 100644 --- a/logzio/handler.py +++ b/logzio/handler.py @@ -72,7 +72,7 @@ class LogzioHandler(logging.Handler): def format_message(self, message): now = datetime.datetime.utcnow() timestamp = now.strftime('%Y-%m-%dT%H:%M:%S') + \ - '.%03d' % (now.microsecond / 1000) + 'Z' + '.%03d' % (now.microsecond / 1000) + 'Z' return_json = { 'logger': message.name, @@ -86,7 +86,9 @@ class LogzioHandler(logging.Handler): if message.exc_info: return_json['exception'] = self.format_exception(message.exc_info) - message.exc_info = None # We want to ignore logging format on exceptions, as we handle those differently + + # We want to ignore logging format on exceptions, as we handle those differently + message.exc_info = None formatted_message = self.format(message) if isinstance(formatted_message, dict): From 4bf2d09062a58b7346c731264355c4d264c171cf Mon Sep 17 00:00:00 2001 From: Roi Rav-Hon Date: Wed, 9 May 2018 20:56:54 +0300 Subject: [PATCH 3/4] More pep8 --- logzio/handler.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/logzio/handler.py b/logzio/handler.py index 59840f2..7906123 100644 --- a/logzio/handler.py +++ b/logzio/handler.py @@ -87,7 +87,8 @@ class LogzioHandler(logging.Handler): if message.exc_info: return_json['exception'] = self.format_exception(message.exc_info) - # We want to ignore logging format on exceptions, as we handle those differently + # We want to ignore default logging formatting on exceptions + # As we handle those differently directly into exception field message.exc_info = None formatted_message = self.format(message) From b532a29d76da9322907f01c44c4c6bdd42dd825d Mon Sep 17 00:00:00 2001 From: Roi Rav-Hon Date: Wed, 9 May 2018 21:02:26 +0300 Subject: [PATCH 4/4] Even more pep8\! --- logzio/handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logzio/handler.py b/logzio/handler.py index 7906123..ac05da7 100644 --- a/logzio/handler.py +++ b/logzio/handler.py @@ -72,7 +72,7 @@ class LogzioHandler(logging.Handler): def format_message(self, message): now = datetime.datetime.utcnow() timestamp = now.strftime('%Y-%m-%dT%H:%M:%S') + \ - '.%03d' % (now.microsecond / 1000) + 'Z' + '.%03d' % (now.microsecond / 1000) + 'Z' return_json = { 'logger': message.name,