From d99e6d1994af4c37a550abebfa8f74d873ad7091 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Sun, 17 Nov 2019 18:55:40 -0800 Subject: [PATCH] Remove obnoxious log message when Healthchecks hook sends failure for check action. --- borgmatic/hooks/healthchecks.py | 5 ++--- tests/unit/hooks/test_healthchecks.py | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/borgmatic/hooks/healthchecks.py b/borgmatic/hooks/healthchecks.py index 1cd9de1a7..19201d0f0 100644 --- a/borgmatic/hooks/healthchecks.py +++ b/borgmatic/hooks/healthchecks.py @@ -53,9 +53,8 @@ def format_buffered_logs_for_payload(): if isinstance(handler, Forgetful_buffering_handler) ) except StopIteration: - payload = 'Cannot find the log handler for sending logs to Healthchecks' - logger.warning(payload) - return payload + # No handler means no payload. + return '' payload = ''.join(message for message in buffering_handler.buffer) diff --git a/tests/unit/hooks/test_healthchecks.py b/tests/unit/hooks/test_healthchecks.py index 0c156e567..cbb9cc76a 100644 --- a/tests/unit/hooks/test_healthchecks.py +++ b/tests/unit/hooks/test_healthchecks.py @@ -46,14 +46,14 @@ def test_format_buffered_logs_for_payload_inserts_truncation_indicator_when_logs assert payload == '...\nfoo\nbar\n' -def test_format_buffered_logs_for_payload_without_handler_produces_payload_anyway(): +def test_format_buffered_logs_for_payload_without_handler_produces_empty_payload(): flexmock(module.logging).should_receive('getLogger').and_return( flexmock(handlers=[module.logging.Handler()]) ) payload = module.format_buffered_logs_for_payload() - assert payload + assert payload == '' def test_ping_monitor_hits_ping_url_for_start_state():