Skip to content

fix: use module logger in MQTT subscribe instead of root logger - #48

Open
sacredserengeti wants to merge 1 commit into
Lash-L:mainfrom
sacredserengeti:fix/mqtt-subscribe-logger-name
Open

fix: use module logger in MQTT subscribe instead of root logger#48
sacredserengeti wants to merge 1 commit into
Lash-L:mainfrom
sacredserengeti:fix/mqtt-subscribe-logger-name

Conversation

@sacredserengeti

Copy link
Copy Markdown

Fixes #47 (the logging half of it).

While debugging #47 I noticed that everything in snoo.py logs via _LOGGER = logging.getLogger(__name__), but the MQTT subscription code added in the PubNub → MQTT migration used bare logging.debug/info/error calls instead. Those all go to the root logger, so when something breaks (like #47), enabling python_snoo debug logging in Home Assistant turns up nothing — the errors only show up under root, 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 in subscribe_mqtt to _LOGGER.*, matching the rest of the file. No behavior change — messages just end up under the python_snoo.snoo logger 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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MQTT connect times out on every attempt (no CONNACK) — entities stay unavailable, subscription never retries

1 participant