Skip to content
Advertisement

Logging with Python, ROS, and C++

I have a codebase of Python and C++ code, including heavy use of ROS. Logging is done throughout the Python code with both system logger and rospy logging — contrived example:

JavaScript

As for C++ code we need to add logging, probably with glog but I’m open to other options.

Is there a way to integrate the various loggers into one module? Ideally a user could do something like my_logger = AwesomeLogger(level='info', output='my_logs.txt') and then AwesomeLogger behind the scenes sets up the Python and C++ loggers, and combines all log outputs (including from ROS) into clean console messages output text file.

Note we target support for ubuntu 16.04, ROS-kinetic, C++11, Python 2.7*

*If a solution provides rational for moving to Python 3.6 you get bonus points!

UPDATE If I load a dict config from yaml (as described in this post on logging best practices I can specify handlers and loggers for ROS. But with the yaml below I get duplicated rospy log messages to the console, one in the standard rospy log format and the other in my specified format. Why??

JavaScript

Advertisement

Answer

This config yaml does the trick:

JavaScript

And to load it,

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement