Ask Your Question
0

rostest does not show log message

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

khu gravatar image

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

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.

kai

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

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

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");

or

ROSCONSOLE_AUTOINIT;

To set the logger level either

ros::start();

or

if(ros::console::set_logger_level(ROSCONSOLE_DEFAULT_NAME, ros::console::levels::Debug))
{
    ros::console::notifyLoggerLevelsChanged();
}

Of course you can just use rosconsole directly

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

int main(int argc, char* argv[])
{
    ROSCONSOLE_AUTOINIT;
    log4cxx::LoggerPtr my_logger = log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME);
    my_logger->setLevel(ros::console::g_level_lookup[ros::console::levels::Debug]);
    ROS_INFO("test logger);
    exit 0;
}
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

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

Seen: 994 times

Last updated: Jul 25 '17