-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log a warning for modules that log too often #139708
base: dev
Are you sure you want to change the base?
Conversation
self._log_counts[logger_name] = LoggerCount(1, now) | ||
return | ||
|
||
ellapsed_time = now - module_count.start_time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: ellapsed
-> elapsed
module_count.start_time = now | ||
return | ||
|
||
module_count.count += 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should only count if level is not debug, as debug log is not something that should be enabled by default and is usually very noisy since you are planning to gather as much as information as possible, I think we don't want this to create a warning as it might drive developers to reduce debug logging which is the opposite of what is debug used to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I would not be able to remove logging from the ZHA modules, for example, that communicate with radios over serial and effectively log nonstop at DEBUG
. This is honestly one of the reasons I dislike the DEBUG < INFO < WARNING divide, as some logging belongs in a TRACE
level that won't be enabled even with DEBUG.
Does this affect modules that log at a lower log level (i.e. too much debug logging), or only those that log with a level that Core is affected by? My understanding of logging here is that as long as we don't perform string interpolation when formatting log messages, it's going to be nearly free unless enabled, no? |
Proposed change
This records how often modules log in a specific time window, and logs a warning for those that do it too often.
This serves as a base for the feature. In the future we could improve this by trying to find which integrations depend on the noisy modules, and guide the user to check if debug logging is enabled for those integrations, for example.
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: