From 8380c4d3cfe290eea43b34157fce19376763b82c Mon Sep 17 00:00:00 2001 From: "whitesource-bolt-for-github[bot]" Date: Sun, 31 Mar 2019 10:00:03 +0000 Subject: [PATCH 1/4] Initial WhiteSource configuration file --- .whitesource | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .whitesource diff --git a/.whitesource b/.whitesource new file mode 100644 index 0000000..f340c5d --- /dev/null +++ b/.whitesource @@ -0,0 +1,8 @@ +########################################################## +#### WhiteSource Integration configuration file #### +########################################################## + +# Configuration # +#---------------# +ws.repo.scan=true +vulnerable.check.run.conclusion.level=failure From ca7be192be6a8e7a26bdc02074c086a87e823a1b Mon Sep 17 00:00:00 2001 From: Emile Fugulin Date: Mon, 15 Apr 2019 10:43:47 -0400 Subject: [PATCH 2/4] Add flag to disable the local backup of logs --- README.md | 1 + logzio/handler.py | 6 ++++-- logzio/sender.py | 6 ++++-- tests/test_logzioSender.py | 14 ++++++++++++++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9ecc9a3..58150b1 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ format={"additional_field": "value"} - Time to sleep between draining attempts (defaults to "3") - Logz.io Listener address (defaults to "https://listener.logz.io:8071") - Debug flag. Set to True, will print debug messages to stdout. (defaults to "False") + - Backup logs flag. Set to False, will disable the local backup of logs in case of failure. (defaults to "True") Please note, that you have to configure those parameters by this exact order. i.e. you cannot set Debug to true, without configuring all of the previous parameters as well. diff --git a/logzio/handler.py b/logzio/handler.py index 8767b61..0b319f3 100644 --- a/logzio/handler.py +++ b/logzio/handler.py @@ -16,7 +16,8 @@ class LogzioHandler(logging.Handler): logzio_type="python", logs_drain_timeout=3, url="https://listener.logz.io:8071", - debug=False): + debug=False, + backup_logs=True): if not token: raise LogzioException('Logz.io Token must be provided') @@ -27,7 +28,8 @@ class LogzioHandler(logging.Handler): token=token, url=url, logs_drain_timeout=logs_drain_timeout, - debug=debug) + debug=debug, + backup_logs=backup_logs) logging.Handler.__init__(self) def extra_fields(self, message): diff --git a/logzio/sender.py b/logzio/sender.py index 7b51d53..6e81b26 100644 --- a/logzio/sender.py +++ b/logzio/sender.py @@ -32,11 +32,13 @@ class LogzioSender: def __init__(self, token, url='https://listener.logz.io:8071', logs_drain_timeout=5, - debug=False): + debug=False, + backup_logs=True): self.token = token self.url = '{}/?token={}'.format(url, token) self.logs_drain_timeout = logs_drain_timeout self.logger = get_logger(debug) + self.backup_logs = backup_logs # Function to see if the main thread is alive self.is_main_thread_active = lambda: any( @@ -144,7 +146,7 @@ class LogzioSender: sleep(sleep_between_retries) sleep_between_retries *= 2 - if should_backup_to_disk: + if should_backup_to_disk and self.backup_logs: # Write to file self.logger.info( 'Could not send logs to Logz.io after %s tries, ' diff --git a/tests/test_logzioSender.py b/tests/test_logzioSender.py index 420688b..90242d3 100644 --- a/tests/test_logzioSender.py +++ b/tests/test_logzioSender.py @@ -108,6 +108,20 @@ class TestLogzioSender(TestCase): line = f.readline() self.assertTrue(log_message in line) + def test_local_file_backup_disabled(self): + log_message = "Backup to local filesystem" + self.logzio_listener.set_server_error() + self.logger.handlers[0].logzio_sender.backup_logs = False + self.logger.info(log_message) + + # Make sure no file is present + self.assertEqual(len(_find("logzio-failures-*.txt", ".")), 0) + + time.sleep(2 * 2 * 2 * 2 * 2) # All of the retries + + # Make sure no file was created + self.assertEqual(len(_find("logzio-failures-*.txt", ".")), 0) + def test_can_send_after_fork(self): childpid = os.fork() child_log_message = 'logged from child process' From f9a97ade6d3f94c4212b7fae89d6072596736991 Mon Sep 17 00:00:00 2001 From: idohalevi Date: Sun, 21 Apr 2019 12:09:47 +0300 Subject: [PATCH 3/4] remove python3.3 from testing --- .travis.yml | 2 -- README.md | 5 +++-- tox.ini | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index ac94a88..4a43456 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,8 +9,6 @@ matrix: env: TOXENV=py3flake8 - python: 2.7 env: TOXENV=py27 - - python: 3.3 - env: TOXENV=py33 - python: 3.4 env: TOXENV=py34 - python: 3.5 diff --git a/README.md b/README.md index 9ecc9a3..614a649 100644 --- a/README.md +++ b/README.md @@ -15,14 +15,15 @@ pip install logzio-python-handler ## Tested Python Versions Travis CI will build this handler and test against: - - "2.7" - - "3.3" + - "2.7" - "3.4" - "3.5" - "3.6" We can't ensure compatibility to any other version, as we can't test it automatically. +**Note**: The Logz.io Python Handler no longer tests Python 3.3 (which was [end-of-lifed](https://www.python.org/dev/peps/pep-0398/#id11) in 2017). + To run tests: ```bash diff --git a/tox.ini b/tox.ini index e45862c..57794c0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] minversion = 1.7.2 -envlist = flake8, py3flake8, py27, py33, py34, py35, py36 +envlist = flake8, py3flake8, py27, py34, py35, py36 skip_missing_interpreters = true [testenv] From e3874b3192c693970ef6c6d6399ea13c988d5d68 Mon Sep 17 00:00:00 2001 From: idohalevi Date: Tue, 23 Apr 2019 10:19:03 +0300 Subject: [PATCH 4/4] update setup.py + readme to version 2.0.12 --- README.md | 1 + setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3a4a891..dae5dba 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,7 @@ LOGGING = { - appname - Your django app ## Release Notes +- 2.0.12 - Support disable logs local backup - 2.0.11 - Completely isolate exception from the message - 2.0.10 - Not ignoring formatting on exceptions - 2.0.9 - Support extra fields on exceptions too (Thanks @asafc64!) diff --git a/setup.py b/setup.py index 570f621..755f218 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.11', + version='2.0.12', description="Logging handler to send logs to your Logz.io account with bulk SSL", keywords="logging handler logz.io bulk https", author="roiravhon",