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

rostest does not show log message

asked 2017-07-24 03:13:22 -0600

khu gravatar image

updated 2017-07-25 04:38:52 -0600

Hi everyone,

I have an annoying problem of dispalying the ros log message during testing. I have some functions showing ROS_ERROR when errors occur and a test program to test these error cases.

If I run a pure gtest program, all ros log messages show up normally in console.

As long as I need to run a test node with rostest, all ros log messages disappear from console. From rostest documentation about the test tag: no output attribute as tests use their own output logging mechanism.

rostest --text also does not help. But if I put std::cout in the test program, rostest will dispaly these messages.

Thanks for any suggestions.


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-04-07 21:29:55 -0600

phillip gravatar image

I have had this issue with setting up GTests in ROS before.

You need to properly initialize the logger and set the logger level in ROS

To initialise the logger either

ros::init(argc, argv, "node_name");



To set the logger level either



if(ros::console::set_logger_level(ROSCONSOLE_DEFAULT_NAME, ros::console::levels::Debug))

Of course you can just use rosconsole directly

#include <ros/console.h>
#include <log4cxx/logger.h>

int main(int argc, char* argv[])
    log4cxx::LoggerPtr my_logger = log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME);
    ROS_INFO("test logger);
    exit 0;
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-07-24 03:13:22 -0600

Seen: 3,047 times

Last updated: Jul 25 '17