From 3586b739366f5225a758d466c4eabf4659f1a2fc Mon Sep 17 00:00:00 2001 From: TomasKuznetsov Date: Tue, 2 Jan 2018 12:14:53 +0200 Subject: [PATCH] Support for extra fields --- README.md | 12 ++++++++++++ setup.py | 2 +- tests/test_logzioHandler.py | 1 - 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6f40337..88b75aa 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,17 @@ except: logger.exception("Supporting exceptions too!") ``` +#### Extra Fields +In case you need to dynamic metadata to your logger, other then the constant metadata from the formatter, you can use the "extra" parameter. +All key values in the dictionary passed in "extra" will be presented in Logz.io as new fields in the log you are sending. +Please note, that you cannot override default fields by the python logger (i.e. lineno, thread, etc..) +For example: + + +``` +logger.info('Warning', extra={'extra_key':'extra_value'}) +``` + ## Django configuration ``` LOGGING = { @@ -127,6 +138,7 @@ LOGGING = { - appname - Your django app ## Release Notes +- 2.0.5 - Support for extra fields - 2.0.4 - Publish package as source along wheel, and supprt python3 packagin (Thanks @cchristous!) - 2.0.3 - Fix bug that consumed more logs while draining than Logz.io's bulk limit - 2.0.2 - Support for formatted messages (Thanks @johnraz!) diff --git a/setup.py b/setup.py index 6d02e81..3700ede 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.4', + version='2.0.5', description="Logging handler to send logs to your Logz.io account with bulk SSL", keywords="logging handler logz.io bulk https", author="roiravhon", diff --git a/tests/test_logzioHandler.py b/tests/test_logzioHandler.py index 88689a7..b65ff27 100644 --- a/tests/test_logzioHandler.py +++ b/tests/test_logzioHandler.py @@ -91,7 +91,6 @@ class TestLogzioHandler(TestCase): record.__dict__["extra_key"] = "extra_value" record.__dict__["module"] = "testing" - formatted_message = self.handler.format_message(record) formatted_message["@timestamp"] = None