fix: use module logger in MQTT subscribe instead of root logger - #48
Open
sacredserengeti wants to merge 1 commit into
Open
fix: use module logger in MQTT subscribe instead of root logger#48sacredserengeti wants to merge 1 commit into
sacredserengeti wants to merge 1 commit into
Conversation
The MQTT subscription code added in the PubNub -> MQTT migration used bare logging.* calls, which send everything to the root logger. All other code in this file uses _LOGGER (logging.getLogger(__name__)). In Home Assistant this meant errors from the MQTT connection only appeared under 'root' and python_snoo debug logging captured nothing from this code path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #47 (the logging half of it).
While debugging #47 I noticed that everything in
snoo.pylogs via_LOGGER = logging.getLogger(__name__), but the MQTT subscription code added in the PubNub → MQTT migration used barelogging.debug/info/errorcalls instead. Those all go to the root logger, so when something breaks (like #47), enablingpython_snoodebug logging in Home Assistant turns up nothing — the errors only show up underroot, and the debug lines don't show at all unless root itself is at debug. Cost me a fair bit of head-scratching before I figured out where the messages were actually going.This swaps the 7 bare
logging.*calls insubscribe_mqttto_LOGGER.*, matching the rest of the file. No behavior change — messages just end up under thepython_snoo.snoologger like everything else.I didn't touch the no-retry issue from #47 since that's a design decision you may want to handle differently, but happy to follow up on it if useful.