Skip to content

Commit 5bed97a

Browse files
committed
logging for errors
1 parent d5ca030 commit 5bed97a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/uros/core.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from rosserial_msgs import TopicInfo
1515
import sys
1616
import os
17+
import logging
1718

1819
# for now threads are used, will be changed with asyncio in the future
1920
if sys.platform == "esp32":
@@ -24,6 +25,8 @@
2425
# rosserial protocol header
2526
header = [0xFF, 0xFE]
2627

28+
logging.basicConfig(level=logging.INFO)
29+
2730
# class to manage publish and subscribe
2831
# COULD BE CHANGED AFTERWARDS
2932
class NodeHandle(object):
@@ -87,7 +90,7 @@ def _advertise_topic(self, topic_name, msg, endpoint, buffer_size):
8790
try:
8891
register.buffer_size = buffer_size
8992
except Exception as e:
90-
print("No buffer size could be defined for topic negotiation.")
93+
logging.info("No buffer size could be defined for topic negotiation.")
9194

9295
# serialization
9396
packet = uio.StringIO()
@@ -164,9 +167,7 @@ def _listen(self):
164167
# incoming object msg initialized
165168
msgobj = self.subscribing_topics.get(inid)[0]
166169
except Exception:
167-
print(
168-
"TX request was made or got message from not available subscribed topic."
169-
)
170+
logging.info("TX request was made or got message from not available subscribed topic.")
170171
# object sent to callback
171172
callback = self.subscribing_topics.get(inid)[1]
172173
fdata = msgobj()
@@ -176,7 +177,7 @@ def _listen(self):
176177
raise ValueError("Message plus Topic ID Checksum is wrong!")
177178

178179
except Exception as e:
179-
print("No incoming data could be read for subscribes.")
180+
logging.info("No incoming data could be read for subscribes.")
180181

181182

182183
# functions to be used in class

0 commit comments

Comments
 (0)