Roscpp error logs never get written to node logfile
This is the code in my roscpp node:
#include "ros/ros.h"
#include <ros/console.h>
int main( int argc, char * argv[]) {
ros::init(argc, argv, "test_node");
sleep( 5 );
ROS_ERROR( "BAR" );
ROS_INFO( "FOO" );
sleep( 5 ); }
My launch file is simple:
<launch>
<node pkg="test_node" type="test_node" name="test_node"> </node>
</launch>
When I run:
roslaunch test_node test_node.launch
I get the following output on the terminal:
process[test_node-1]: started with pid [25327]
[ERROR] [1606373695.024750165]: BAR
[test_node-1] process has finished cleanly
log file: /home/me/.ros/log/acd2a32a-2f9b-11eb-9f56-9cfce822015a/test_node-1*.log
all processes on machine have died, roslaunch will exit
shutting down processing monitor...
... shutting down processing monitor complete
done
When I look in the node log file in /home/me/.ros/log/latest/test_node-1-stdout.log
I only see the INFO log "FOO" but I don't see the ERROR log "BAR".
Why?
I've tried this a hundred different ways considering process buffers being flushed etc... and boiled it down to this.
Even if instead of exiting I ros::spin() and let it run and then ctrl-c I still get the INFO but no ERROR in the log file.
The fact that the info log gets there and the error doesn't is driving me mad.
I've tried redirecting stderr to stdout for the roslaunch process - no luck.
Flushing makes no difference.
How the node exits (assert, graceful) no difference.
I think there is a bug in roslaunch or rosconcole.
This is on ROS melodic on ubuntu 18.04