Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0c13416

Browse files
committed
MQTT supports publishing messages with string or
byte payloads. But our logging module only supports strings. Hence replaced line 37 with code that stringified message when possible.
1 parent 599690e commit 0c13416

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

clearblade/Messaging.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,13 @@ def unsubscribe(self, channel):
134134
self.__mqttc.unsubscribe(channel)
135135

136136
def publish(self, channel, message, qos=0, retain=False):
137-
cbLogs.info("Publishing", message, "to", channel, ".")
137+
msgType = type(message).__name__
138+
try:
139+
if msgType == "str":
140+
logMsg = message
141+
else:
142+
logMsg = str(message)
143+
except:
144+
logMsg = "unstringifiable object"
145+
cbLogs.info("Publishing", logMsg, "to", channel, ".")
138146
self.__mqttc.publish(channel, message, qos, retain)

0 commit comments

Comments
 (0)