Support toggling debug logging for custom components (#90340)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
71b5ccee23
commit
9f04c23414
2 changed files with 57 additions and 5 deletions
|
@ -66,13 +66,14 @@ def _chattiest_log_level(level1: int, level2: int) -> int:
|
|||
return min(level1, level2)
|
||||
|
||||
|
||||
async def get_integration_loggers(hass: HomeAssistant, domain: str) -> list[str]:
|
||||
async def get_integration_loggers(hass: HomeAssistant, domain: str) -> set[str]:
|
||||
"""Get loggers for an integration."""
|
||||
loggers = [f"homeassistant.components.{domain}"]
|
||||
loggers: set[str] = {f"homeassistant.components.{domain}"}
|
||||
with contextlib.suppress(IntegrationNotFound):
|
||||
integration = await async_get_integration(hass, domain)
|
||||
loggers.add(integration.pkg_path)
|
||||
if integration.loggers:
|
||||
loggers.extend(integration.loggers)
|
||||
loggers.update(integration.loggers)
|
||||
return loggers
|
||||
|
||||
|
||||
|
@ -188,7 +189,7 @@ class LoggerSettings:
|
|||
if settings.type == LogSettingsType.INTEGRATION:
|
||||
loggers = await get_integration_loggers(hass, domain)
|
||||
else:
|
||||
loggers = [domain]
|
||||
loggers = {domain}
|
||||
|
||||
combined_logs = {logger: LOGSEVERITY[settings.level] for logger in loggers}
|
||||
# Don't override the log levels with the ones from YAML
|
||||
|
@ -203,7 +204,7 @@ class LoggerSettings:
|
|||
if settings.type == LogSettingsType.INTEGRATION:
|
||||
loggers = await get_integration_loggers(hass, domain)
|
||||
else:
|
||||
loggers = [domain]
|
||||
loggers = {domain}
|
||||
|
||||
for logger in loggers:
|
||||
combined_logs[logger] = LOGSEVERITY[settings.level]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue