From 2c206c18d414703aaaec358f6548a0d4f1be5b48 Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Mon, 3 Jun 2024 23:38:31 +0200 Subject: [PATCH] Do not log mqtt origin info if the log level does not allow it (#118752) --- homeassistant/components/mqtt/discovery.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/homeassistant/components/mqtt/discovery.py b/homeassistant/components/mqtt/discovery.py index 2cdd900690c..e8a3ed9a8cb 100644 --- a/homeassistant/components/mqtt/discovery.py +++ b/homeassistant/components/mqtt/discovery.py @@ -82,6 +82,9 @@ def async_log_discovery_origin_info( message: str, discovery_payload: MQTTDiscoveryPayload, level: int = logging.INFO ) -> None: """Log information about the discovery and origin.""" + if not _LOGGER.isEnabledFor(level): + # bail early if logging is disabled + return if CONF_ORIGIN not in discovery_payload: _LOGGER.log(level, message) return