logging system

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

logging system

yanmingz
Hi Mathieu,

Could the logging tool in RTAB-Map print process ID in log files?

Currently log4cxx is very popular. What are the main differences in functions between your logging tool and log4cxx?

Best regards
Yanming
Reply | Threaded
Open this post in threaded view
|

Re: logging system

matlabbe
Administrator
Hi Yanming,

I added an option to print the thread ID of the thread logging. I added it in the Preferences dialog->Logging. In code, you should call "ULogger::setPrintThreadId(true)". Example (ID is shown between the braces "{}"):
[DEBUG] {140735243305744} (2016-01-05 12:50:51.369) MainWindow.cpp:1612::updateMapCloud() Hide cloud3
[DEBUG] {140735243305744} (2016-01-05 12:50:51.370) CloudViewer.cpp:546::addCloud() Adding graph_0_nodes with 4 points
[DEBUG] {140735243305744} (2016-01-05 12:50:51.380) MainWindow.cpp:1348::processStats() time= 29 ms
[DEBUG] {140735243305744} (2016-01-05 12:50:51.380) MainWindow.cpp:1394::processStats() 
[ INFO] {140735243305744} (2016-01-05 12:50:51.380) MainWindow.cpp:1406::processStats() Updating GUI time = 0.040000s
[DEBUG] {4779139072} (2016-01-05 12:50:52.138) Camera.cpp:88::takeImage() slept=1.000000s vs target=1.000000s
[DEBUG] {4779139072} (2016-01-05 12:50:52.148) Camera.cpp:101::takeImage() Time capturing image = 0.009702s
[DEBUG] {4779139072} (2016-01-05 12:50:52.148) CameraThread.cpp:74::mainLoop() 
[DEBUG] {4778602496} (2016-01-05 12:50:52.148) Memory.cpp:506::update() 
[DEBUG] {4778602496} (2016-01-05 12:50:52.148) Memory.cpp:515::update() pre-updating...
[DEBUG] {4778602496} (2016-01-05 12:50:52.148) Memory.cpp:3354::cleanUnusedWords() Removing 0 words (dictionary size=633)...
[DEBUG] {4778602496} (2016-01-05 12:50:52.148) Memory.cpp:519::update() time preUpdate=0.036955 ms
[DEBUG] {4778602496} (2016-01-05 12:50:52.148) Memory.cpp:2954::createSignature() 
[DEBUG] {4778602496} (2016-01-05 12:50:52.148) Memory.cpp:3027::createSignature() Start dictionary update thread
[DEBUG] {4800000000} (2016-01-05 12:50:52.148) VWDictionary.cpp:530::update()

The logger in RTAB-Map is taken from one of my past personal utilities project (UtiLite), and works like ROS_* log defines (like a printf). log4cxx can be used in similar ways:
UtilLite:
UDEBUG(expression)
UINFO(expression)
UWARN(expression)
UERROR(expression)
UFATAL(expression)

ROS:
ROS_DEBUG(expression)
ROS_INFO(expression)
ROS_WARN(expression)
ROS_ERROR(expression)
ROS_FATAL(expression)

log4cxx:
LOG4CXX_DEBUG(logger, expression)
LOG4CXX_INFO(logger, expression)
LOG4CXX_WARN(logger, expression)
LOG4CXX_ERROR(logger, expression)
LOG4CXX_FATAL(logger, expression)
ROS and UtiLite print with color, don't know about log4cxx. With log4cxx, you can select a specified logger, which can inherit from a parent logger. You can then have more control on which part of the code you want a debug trace, which is not possible in RTAB-Map (all logs with level >= to one set are shown). For my usage, a verbose level is enough though.

The logger in ROS can log over the network, which is better when you have multiple nodes to debug. You can see that rtabmap_ros uses ROS logger and rtabmap library uses UtiLite logger.

cheers,
Mathieu