fix: Lower log level for mqtt channel publish exceptions#696
fix: Lower log level for mqtt channel publish exceptions#696allenporter merged 1 commit intoPython-roborock:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR reduces the logging level for MQTT publish exceptions from exception to debug in the mqtt_channel.py file. The change affects error logging when MQTT message publishing fails, though the exception is still re-raised to the caller.
- Lowers log level from
exception()todebug()for MQTT publish errors
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return await self._mqtt_session.publish(self._publish_topic, encoded_msg) | ||
| except MqttSessionException as e: | ||
| self._logger.exception("Error publishing MQTT message: %s", e) | ||
| self._logger.debug("Error publishing MQTT message: %s", e) |
There was a problem hiding this comment.
Using debug() instead of exception() loses the stack trace information from the caught exception. When an exception is caught and re-raised, using logger.exception() automatically includes the full stack trace, which is valuable for debugging. If lowering the log level is intentional, consider using logger.debug("Error publishing MQTT message: %s", e, exc_info=True) to retain the stack trace at debug level.
| self._logger.debug("Error publishing MQTT message: %s", e) | |
| self._logger.debug("Error publishing MQTT message: %s", e, exc_info=True) |
| return await self._mqtt_session.publish(self._publish_topic, encoded_msg) | ||
| except MqttSessionException as e: | ||
| self._logger.exception("Error publishing MQTT message: %s", e) | ||
| self._logger.debug("Error publishing MQTT message: %s", e) |
There was a problem hiding this comment.
Inconsistent logging levels within the same method. The encoding error at line 85 uses logger.exception(), while this publishing error now uses logger.debug(). Both exceptions are caught and re-raised in the same way, so they should use the same logging level for consistency. Consider using the same logging approach for both error cases.
| self._logger.debug("Error publishing MQTT message: %s", e) | |
| self._logger.exception("Error publishing MQTT message: %s", e) |
No description provided.