Skip to content

Commit cae015d

Browse files
authored
Merge pull request #11 from bcmi-labs/logging_levels
ucloud: Update logging messages and levels.
2 parents b500d96 + 816a86f commit cae015d

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

arduino_iot_cloud/ucloud.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ def value(self, value):
106106
)
107107
self._updated = True
108108
self.timestamp = timestamp()
109-
logging.debug(
110-
f"record: {self.name} %s: {value} ts: {self.timestamp}"
111-
% ("initialized" if self.value is None else "updated")
112-
)
109+
if (self.value is None):
110+
logging.info(f"Init: {self.name} value: {value} ts: {self.timestamp}")
111+
else:
112+
logging.debug(f"Update: {self.name} value: {value} ts: {self.timestamp}")
113113
self._value = value
114114

115115
def __is_subrecord(self, attr):
@@ -218,7 +218,7 @@ def update_systime(self):
218218

219219
def create_task(self, name, coro, *args, **kwargs):
220220
self.tasks[name] = asyncio.create_task(coro(*args))
221-
logging.debug(f"task: {name} created.")
221+
logging.info(f"task: {name} created.")
222222

223223
def create_topic(self, topic, inout):
224224
return bytes(f"/a/t/{self.thing_id}/{topic}/{inout}", "utf-8")
@@ -244,9 +244,9 @@ def senml_generic_callback(self, record, **kwargs):
244244
# This callback catches all unknown/umatched sub/records that were not part of the pack.
245245
rname, sname = record.name.split(":") if ":" in record.name else [record.name, None]
246246
if rname in self.records:
247-
logging.debug(f"Ignoring cloud initialization for record: {record.name}")
247+
logging.info(f"Ignoring cloud initialization for record: {record.name}")
248248
else:
249-
logging.info(f"Unkown record found: {record.name} value: {record.value}")
249+
logging.warning(f"Unkown record found: {record.name} value: {record.value}")
250250

251251
def mqtt_callback(self, topic, message):
252252
logging.debug(f"mqtt topic: {topic[-8:]}... message: {message[:8]}...")
@@ -285,7 +285,7 @@ async def mqtt_task(self, interval=0.100):
285285
record.add_to_pack(self.senmlpack, push=True)
286286
if len(self.senmlpack._data):
287287
logging.debug("Pushing records to Arduino IoT cloud:")
288-
for record in self.senmlpack:
288+
for record in self.senmlpack._data:
289289
logging.debug(f" ==> record: {record.name} value: {str(record.value)[:48]}...")
290290
self.mqtt.publish(self.topic_out, self.senmlpack.to_cbor(), qos=True)
291291
self.last_ping = timestamp()

arduino_iot_cloud/umqtt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def connect(self, retry=10, interval=1.0, clean_session=True):
151151
return True
152152
except Exception as e:
153153
self.sock.close()
154-
logging.info(f"Connection failed {e}, retrying after {interval}s")
154+
logging.warning(f"Connection failed {e}, retrying after {interval}s")
155155
time.sleep(interval)
156156
return False
157157

@@ -198,7 +198,7 @@ def publish(self, topic, msg, retain=False, qos=0):
198198
assert 0
199199

200200
def subscribe(self, topic, qos=0):
201-
logging.info(f"Subscribing to topic: {topic}.")
201+
logging.info(f"Subscribe: {topic}.")
202202
assert self.cb is not None, "Subscribe callback is not set"
203203
pkt = bytearray(b"\x82\0\0\0")
204204
self.pid += 1

0 commit comments

Comments
 (0)