mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 17:57:55 +00:00
Limit mqtt info logging for discovery of new components (#142344)
* Limit mqtt info logging for discovery of new component * Keep in bail out, when debug logging is not enabled
This commit is contained in:
parent
660cbc136f
commit
ae0f27c42f
@ -154,18 +154,14 @@ def get_origin_support_url(discovery_payload: MQTTDiscoveryPayload) -> str | Non
|
|||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_log_discovery_origin_info(
|
def async_log_discovery_origin_info(
|
||||||
message: str, discovery_payload: MQTTDiscoveryPayload, level: int = logging.INFO
|
message: str, discovery_payload: MQTTDiscoveryPayload
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Log information about the discovery and origin."""
|
"""Log information about the discovery and origin."""
|
||||||
# We only log origin info once per device discovery
|
if not _LOGGER.isEnabledFor(logging.DEBUG):
|
||||||
if not _LOGGER.isEnabledFor(level):
|
# bail out early if debug logging is disabled
|
||||||
# bail out early if logging is disabled
|
|
||||||
return
|
return
|
||||||
_LOGGER.log(
|
_LOGGER.debug(
|
||||||
level,
|
"%s%s", message, get_origin_log_string(discovery_payload, include_url=True)
|
||||||
"%s%s",
|
|
||||||
message,
|
|
||||||
get_origin_log_string(discovery_payload, include_url=True),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -562,7 +558,7 @@ async def async_start( # noqa: C901
|
|||||||
elif already_discovered:
|
elif already_discovered:
|
||||||
# Dispatch update
|
# Dispatch update
|
||||||
message = f"Component has already been discovered: {component} {discovery_id}, sending update"
|
message = f"Component has already been discovered: {component} {discovery_id}, sending update"
|
||||||
async_log_discovery_origin_info(message, payload, logging.DEBUG)
|
async_log_discovery_origin_info(message, payload)
|
||||||
async_dispatcher_send(
|
async_dispatcher_send(
|
||||||
hass, MQTT_DISCOVERY_UPDATED.format(*discovery_hash), payload
|
hass, MQTT_DISCOVERY_UPDATED.format(*discovery_hash), payload
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user