From 5bed97ab6eb7233881d47cac472a8a8ee7b7ed4f Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 19 Sep 2020 22:15:53 -0500 Subject: [PATCH] logging for errors --- src/uros/core.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/uros/core.py b/src/uros/core.py index 7143102..1f441a9 100644 --- a/src/uros/core.py +++ b/src/uros/core.py @@ -14,6 +14,7 @@ from rosserial_msgs import TopicInfo import sys import os +import logging # for now threads are used, will be changed with asyncio in the future if sys.platform == "esp32": @@ -24,6 +25,8 @@ # rosserial protocol header header = [0xFF, 0xFE] +logging.basicConfig(level=logging.INFO) + # class to manage publish and subscribe # COULD BE CHANGED AFTERWARDS class NodeHandle(object): @@ -87,7 +90,7 @@ def _advertise_topic(self, topic_name, msg, endpoint, buffer_size): try: register.buffer_size = buffer_size except Exception as e: - print("No buffer size could be defined for topic negotiation.") + logging.info("No buffer size could be defined for topic negotiation.") # serialization packet = uio.StringIO() @@ -164,9 +167,7 @@ def _listen(self): # incoming object msg initialized msgobj = self.subscribing_topics.get(inid)[0] except Exception: - print( - "TX request was made or got message from not available subscribed topic." - ) + logging.info("TX request was made or got message from not available subscribed topic.") # object sent to callback callback = self.subscribing_topics.get(inid)[1] fdata = msgobj() @@ -176,7 +177,7 @@ def _listen(self): raise ValueError("Message plus Topic ID Checksum is wrong!") except Exception as e: - print("No incoming data could be read for subscribes.") + logging.info("No incoming data could be read for subscribes.") # functions to be used in class