[ROS Q&A] Setting the node log level in run time (C++)

Written by Ricardo Tellez

21/11/2017

In this video we show how to use C++ to dynamically change the logger level of a node. See the original question: https://answers.ros.org/question/276242/set-log-level-for-each-node-in-ros-cpp/

Q: Set log level for each node in ROS CPP

A: You basically have to use the rosconsole class of roscpp (ros.h) to change the logger level. After importing console.h you need to do the following code call: ros::console::set_logger_level(ROSCONSOLE_DEFAULT_NAME, ros::console::levels::Debug)

As you can see, the last argument indicates the level of debug you want to have for that node. After that call, you must notify, that the logger level has changed. For that, do the following:

ros::console::notifyLoggerLevelsChanged()

That is all! That simple.

Topics:
Masterclass 2023 batch2 blog banner

Check Out These Related Posts

0 Comments

Submit a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Pin It on Pinterest

Share This