-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
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
Add vesync debug mode in library #134571
Add vesync debug mode in library #134571
Conversation
Hey there @markperdue, @webdjoe, @TheGardenMonkey, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
That will work but it requires restarting the integration. Can we list to the event EVENT_LOGGING_CHANGED like |
That's indeed a good point, we should be able to change it on runtime for the best experience. Why do we actually overwrite this in the lib as opposed to just logging in debug? |
Good question, I'm not sure why the library over writes it. @webdjoe thoughts? |
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.
There's a merge conflict
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Fixed. |
@joostlek merge conflicts resolved. Thoughts around this one? I dug into try tell the exact code blocking runtime changes in the library but couldn't find it. This would be helpful for the future releases when debug is needed. |
I second the useful of this even if it was not perfect. #138004 calls out an issue which I suspect is due to failure reported at vesync web end. I know the web call returns a message but can only be seen if debug logging is enabled in the library. |
I can remove the logging hooks in the library, but a thought may be not to override by default, only when the property / argument is set. This just makes it easier to debug when developing but I'm open to suggestions. |
That works for me. Hopefully removes the need for this. |
@callback | ||
def _async_handle_logging_changed(_event: Event) -> None: | ||
"""Handle when the logging level changes.""" | ||
manager.debug = logging.getLogger("pyvesync.vesync").level == logging.DEBUG |
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.
Why doesn't the library use the standard Python logging mechanism and best practice with just using a logger per module or package? Why does it need this attribute on the manager?
Eg:
LOGGER = logging.getLogger(__name__)
LOGGER.debug("bla bla")
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.
Just how it was written - as webdjoe mentioned a re-write of the library is coming that will solve this. If we merge this current code it gives us debug ability until that happens.
It would get removed on the re-write update.
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.
It's ok for now. The library should preferably be updated ASAP so we can remove this.
Please press ready for review when we're ready to merge. |
Ready for review. |
Proposed change
Previously debug mode for the logger didn't pass to pyvesync library. The library overrides the settings back to default. Instead it has a flag you can pass in. This takes the debug mode setting and passes to the library allowing the standard debug functions to work. It also has listeners to adjust this on the fly.
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: