diff --git a/README.md b/README.md index 183bb58..fad58f3 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,7 @@ LOGGING = { - appname - Your django app ## Release Notes +- 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!) - 2.0.1 - Added __all__ to __init__.py, so support * imports - 2.0.0 - Production, stable release. diff --git a/logzio/sender.py b/logzio/sender.py index e504c6d..35bfb93 100644 --- a/logzio/sender.py +++ b/logzio/sender.py @@ -11,7 +11,7 @@ if sys.version[0] == '2': else: import queue as queue -MAX_BULK_SIZE_IN_BYTES = 3 * 1024 * 1024 # 3 MB +MAX_BULK_SIZE_IN_BYTES = 1 * 1024 * 1024 # 1 MB def backup_logs(logs): @@ -112,8 +112,11 @@ class LogzioSender: def _get_messages_up_to_max_allowed_size(self): logs_list = [] + current_size = 0 while not self.queue.empty(): - logs_list.append(self.queue.get()) - if sys.getsizeof(logs_list) >= MAX_BULK_SIZE_IN_BYTES: + current_log = self.queue.get() + current_size += sys.getsizeof(current_log) + logs_list.append(current_log) + if current_size >= MAX_BULK_SIZE_IN_BYTES: break return logs_list diff --git a/setup.py b/setup.py index 5fd5778..438f2a8 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.2', + version='2.0.3', description="Logging handler to send logs to your Logz.io account with bulk SSL", keywords="logging handler logz.io bulk https", author="roiravhon",