From 1620831da22308ea50a8a44ce3e30a52cf13d028 Mon Sep 17 00:00:00 2001 From: ralongit Date: Wed, 5 Jul 2023 11:10:59 +0300 Subject: [PATCH] Update --- README.md | 2 ++ logzio-failures-04072023-110807.txt | 1 - logzio/handler.py | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) delete mode 100644 logzio-failures-04072023-110807.txt diff --git a/README.md b/README.md index bc2e275..b90e022 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,7 @@ The following additional code example offers the same functionlites that availav from logzio.handler import ExtraFieldsLogFilter def main(): + logger.info("Test log") # Outputs: {"message":"Test log"} extra_fields = {"foo":"bar","counter":1} @@ -183,6 +184,7 @@ def main(): # If you'd like to remove filters from future logs using the logger.removeFilter option: logger.removeFilter(ExtraFieldsLogFilter(error_fields)) logger.debug("Debug test log") # Outputs: {"message":"Debug test log","foo":"bar","counter":1} + ``` ## Django configuration diff --git a/logzio-failures-04072023-110807.txt b/logzio-failures-04072023-110807.txt deleted file mode 100644 index f82c9bd..0000000 --- a/logzio-failures-04072023-110807.txt +++ /dev/null @@ -1 +0,0 @@ -{"logger": "test", "line_number": 102, "path_name": "/Users/raulgurshumov/Desktop/logzio/logzio-python-handler/tests/test_logzioSender.py", "log_level": "INFO", "type": "type", "message": "Backup to local filesystem", "@timestamp": "2023-07-04T08:07:58.949Z", "key": "value"} \ No newline at end of file diff --git a/logzio/handler.py b/logzio/handler.py index 019e882..bf17d27 100644 --- a/logzio/handler.py +++ b/logzio/handler.py @@ -8,6 +8,7 @@ import logging.handlers from .sender import LogzioSender from .exceptions import LogzioException + class ExtraFieldsLogFilter(logging.Filter): def __init__(self, extra: dict, *args, **kwargs): @@ -18,6 +19,7 @@ class ExtraFieldsLogFilter(logging.Filter): record.__dict__.update(self.extra) return True + class LogzioHandler(logging.Handler): def __init__(self, @@ -104,7 +106,7 @@ pip install 'logzio-python-handler[opentelemetry-logging]'""") 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,