Do not log mqtt origin info if the log level does not allow it (#118752)

pull/118845/head
Jan Bouwhuis 2024-06-03 23:38:31 +02:00 committed by Franck Nijhof
parent 7bbfb1a22b
commit 70d7cedf08
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
1 changed files with 3 additions and 0 deletions

View File

@ -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