ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I have tested the code segments about the two existed answers on my ubuntu 16.04 with ros kinetic version, it failed. After my exploration, now the right way to access logger level is in the following:

std::map< std::string, ros::console::levels::Level> logger;
ros::console::get_loggers(logger);
std::cout << "current logger: " << logger[ROSCONSOLE_DEFAULT_NAME] << "\n";

And a tip to all of you, the object logger can't be reused, it means if you want to get logger level after you have changed the logger level, you must create a new object with std::map< std::string, ros::console::levels::Level>, hope this can help you.

I have tested the code segments about the two existed answers on my ubuntu 16.04 with ros kinetic version, it failed. After my exploration, now the right way to access logger level is in the following:

std::map< std::string, ros::console::levels::Level> logger;
ros::console::get_loggers(logger);
std::cout << "current logger: " << logger[ROSCONSOLE_DEFAULT_NAME] << "\n";

And a tip to all of you, the object logger can't be reused, it means if you want to get logger level after you have changed the logger level, it, you must create a new object with std::map< std::string, ros::console::levels::Level>, hope this can help you.