-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add page about logging in an integration #3042
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,35 @@ | ||||||
| --- | ||||||
| title: "Logging" | ||||||
| --- | ||||||
| A good way to find out what is going on in an integration is to have it log what it is doing. | ||||||
|
|
||||||
| :::warning | ||||||
| Please make sure not to spam the logs, as that will make it harder to find the relevant information and may cause performance issues. | ||||||
| ::: | ||||||
|
|
||||||
| ## Debug logging | ||||||
|
|
||||||
| By default, Home Assistant does not log debug messages. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe reword this to something like "In order to enable additional modules logged when the user enables logs for an integration, set the modules i the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I started this paragraph more explaining what debug logs are and how they can help the developer with diagnosing issues. That was my goal at least. So more of a, this is debug logging, a non-intrusive way of fetching a stream of information on demand, and this is how the user enables it and what shouldn't be logged. Not saying that your suggestion is bad, more trying to explain my thought process behind it |
||||||
| Debug logging can be enabled for the integration by the user as described in the [user documentation]. | ||||||
| Enabling debug logging will set the log level for the integration module and for the module declared in the manifest to debug. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use plural "modules" for accuracy. The phrase "the module declared in the manifest" implies a single module, but the 📝 Suggested fix-Enabling debug logging will set the log level for the integration module and for the module declared in the manifest to debug.
+Enabling debug logging will set the log level for the integration module and for the modules listed in the manifest's `loggers` field to debug.📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| So when debug logging is enabled for the following integration, it will set the log level to debug for both the `my_integration` and `dependency` modules: | ||||||
| ```json | ||||||
| { | ||||||
| "domain": "my_integration", | ||||||
| "name": "My Integration", | ||||||
| "loggers": ["dependency"], | ||||||
| "requirements": ["dependency==0.2.1"] | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| :::warning | ||||||
| Make sure to not log sensitive information, as debug logs may be shared with others when troubleshooting issues. | ||||||
| ::: | ||||||
|
|
||||||
| To enable debug logs for a specific module, users can either add `logger` configuration as described in [the logger documentation]. | ||||||
| Or they can use the [`logger.set_level`] service to set the log level for the module to debug. | ||||||
|
|
||||||
| [user documentation]: https://www.home-assistant.io/docs/configuration/troubleshooting/#enabling-debug-logging | ||||||
| [`logger.set_level`]: https://www.home-assistant.io/integrations/logger/#action-set-level | ||||||
| [the logger documentation]: https://www.home-assistant.io/integrations/logger/ | ||||||
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 would suggest rewording this section to be about "dependency logging", since it is not about debug logs only.
If the user has set the default logging to
errorand then sets it toinfofor the integration, this will also loginfologs for the things listed inloggers, right?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.
Well it's not only about dependencies, because it's about how logging is enabled for both the integration module and the dependency.
You can't set the logging for an integration to info, if you do that via the
loggingmodule, I believe it literally only does that for that module, so it's not looking at "oh you loghomeassistant.components.smartthings, let me also setpysmartthingsto the same level"