Skip to content

ucloud: Update logging messages and levels. #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions arduino_iot_cloud/ucloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ def value(self, value):
)
self._updated = True
self.timestamp = timestamp()
logging.debug(
f"record: {self.name} %s: {value} ts: {self.timestamp}"
% ("initialized" if self.value is None else "updated")
)
if (self.value is None):
logging.info(f"Init: {self.name} value: {value} ts: {self.timestamp}")
else:
logging.debug(f"Update: {self.name} value: {value} ts: {self.timestamp}")
self._value = value

def __is_subrecord(self, attr):
Expand Down Expand Up @@ -218,7 +218,7 @@ def update_systime(self):

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

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

def mqtt_callback(self, topic, message):
logging.debug(f"mqtt topic: {topic[-8:]}... message: {message[:8]}...")
Expand Down Expand Up @@ -285,7 +285,7 @@ async def mqtt_task(self, interval=0.100):
record.add_to_pack(self.senmlpack, push=True)
if len(self.senmlpack._data):
logging.debug("Pushing records to Arduino IoT cloud:")
for record in self.senmlpack:
for record in self.senmlpack._data:
logging.debug(f" ==> record: {record.name} value: {str(record.value)[:48]}...")
self.mqtt.publish(self.topic_out, self.senmlpack.to_cbor(), qos=True)
self.last_ping = timestamp()
Expand Down
4 changes: 2 additions & 2 deletions arduino_iot_cloud/umqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def connect(self, retry=10, interval=1.0, clean_session=True):
return True
except Exception as e:
self.sock.close()
logging.info(f"Connection failed {e}, retrying after {interval}s")
logging.warning(f"Connection failed {e}, retrying after {interval}s")
time.sleep(interval)
return False

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

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