diff --git a/changelog/68055.fixed.md b/changelog/68055.fixed.md new file mode 100644 index 000000000000..48f50d2e6dee --- /dev/null +++ b/changelog/68055.fixed.md @@ -0,0 +1 @@ +log_beacon - remove verbose minion log output diff --git a/salt/beacons/log_beacon.py b/salt/beacons/log_beacon.py index 52227cd09cb3..e551865c43ef 100644 --- a/salt/beacons/log_beacon.py +++ b/salt/beacons/log_beacon.py @@ -35,7 +35,6 @@ def __virtual__(): if not salt.utils.platform.is_windows() and HAS_REGEX: return __virtualname__ err_msg = "Not available for Windows systems or when regex library is missing." - log.error("Unable to load %s beacon: %s", __virtualname__, err_msg) return False, err_msg @@ -117,7 +116,7 @@ def beacon(config): fp_.seek(loc) txt = fp_.read() - log.info("txt %s", txt) + log.trace("txt %s", txt) d = {} for tag in config.get("tags", {}): diff --git a/tests/pytests/unit/beacons/test_log_beacon.py b/tests/pytests/unit/beacons/test_log_beacon.py index 18184936d9d2..1a7ad5706b0f 100644 --- a/tests/pytests/unit/beacons/test_log_beacon.py +++ b/tests/pytests/unit/beacons/test_log_beacon.py @@ -5,6 +5,8 @@ log beacon test cases """ +import logging + import pytest import salt.beacons.log_beacon as log_beacon @@ -38,22 +40,30 @@ def test_empty_config(): assert ret == (False, "Configuration for log beacon must contain file option.") -def test_log_match(stub_log_entry): +def test_log_match(stub_log_entry, caplog): with patch("salt.utils.files.fopen", mock_open(read_data=stub_log_entry)): - config = [ - {"file": "/var/log/auth.log", "tags": {"sshd": {"regex": ".*sshd.*"}}} - ] - - ret = log_beacon.validate(config) - assert ret == (True, "Valid beacon configuration") - - _expected_return = [ - { - "error": "", - "match": "yes", - "raw": stub_log_entry.rstrip("\n"), - "tag": "sshd", - } - ] - ret = log_beacon.beacon(config) - assert ret == _expected_return + with caplog.at_level(logging.TRACE): + config = [ + {"file": "/var/log/auth.log", "tags": {"sshd": {"regex": ".*sshd.*"}}} + ] + + ret = log_beacon.validate(config) + assert ret == (True, "Valid beacon configuration") + + _expected_return = [ + { + "error": "", + "match": "yes", + "raw": stub_log_entry.rstrip("\n"), + "tag": "sshd", + } + ] + + ret = log_beacon.beacon(config) + assert ret == _expected_return + for record in caplog.records: + if record.msg.startswith("txt"): + assert record.levelname == "TRACE" + break + else: + assert False, "expected one TRACE txt log"