Add pylint check for info logger messages in components
Proposed change
Add a pylint check which checks if a informational logger message is used in components.
Type of change
- [ ] Dependency upgrade
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New integration (thank you!)
- [ ] New feature (which adds functionality to an existing integration)
- [ ] Deprecation (breaking change to happen in the future)
- [ ] Breaking change (fix/feature causing existing functionality to break)
- [x] Code quality improvements to existing code or addition of tests
Additional information
- This PR fixes or closes issue: fixes #
- This PR is related to issue:
- Link to documentation pull request:
Checklist
- [x] The code change is tested and works locally.
- [x] Local tests pass. Your PR cannot be merged unless tests pass
- [x] There is no commented out code in this PR.
- [x] I have followed the development checklist
- [x] I have followed the perfect PR recommendations
- [x] The code has been formatted using Ruff (
ruff format homeassistant tests) - [ ] Tests have been added to verify that the new code works.
If user exposed functionality or configuration variables are added/changed:
- [ ] Documentation added/updated for www.home-assistant.io
If the code communicates with devices, web services, or third-party tools:
- [ ] The manifest file has all fields filled out correctly.
Updated and included derived files by running:python3 -m script.hassfest. - [ ] New or updated dependencies have been added to
requirements_all.txt.
Updated by runningpython3 -m script.gen_requirements_all. - [ ] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
To help with the load of incoming pull requests:
- [x] I have reviewed two other open pull requests in this repository.
even I somewhat understand the intention of this, but was there a discussion about this? Do we really want to disallow info messages from components other than "core" components?
It's actually the only thing I can confidently find in the dev docs
https://developers.home-assistant.io/docs/development_guidelines#log-messages
I now also notice that the text is probably from the time we were still ordered platform wise
Also note that _LOGGER.info is reserved for the core, use _LOGGER.debug for anything else.
tbh wasn't aware about this sentence in the docs 🙈 but (as I said before) I somehow understand this decision or requirement 👍
Haha I know but I wanted to give the background.
It's mostly history and if you try to add one today Martin will probably let you know ;)
I think it's a nice change and now that I'm seeing how much we log on info, it'll probably clean up a lot of logs for a lot of people
I think it's a nice change and now that I'm seeing how much we log on info, it'll probably clean up a lot of logs for a lot of people
I think so too. I think there are cases where a component can use the INFO level, but the usage should be chosen wisely
I think this moment is a good one to evaluate them. I think the info ones don't even show up in system -> logs, only the warning and error ones
When nothing is configured for logger (so keep the default), than the default log level is warning, so even the full log mostly wouldn't contain info messages.
I don't see an explanation as for why we want to add a pylint check for this? Why do we effectively reduce the number of standard log levels from 4 to 3?
Also note that _LOGGER.info is reserved for the core, use _LOGGER.debug for anything else.
Yes, there's this 5 year old sentence in the documentation, but removing all the info logs from integrations should not have been done without some discussion.
We discussed this in the core team with this conclusion:
- There's no reason to forbid integrations from logging with level INFO
- We don't want the pylint check (this PR)
- Idea by @edenhaus to change the default log level of homeassitant.components from info to warning
- Update documentation:
- Don't forbid info: https://github.com/home-assistant/developers.home-assistant/pull/2358
- Update quality scale docs to say disconnect / reconnect should be logged at info level, @joostlek will add this to the quality scale overhaul