"Warning: recursive print statement has occurred. [...]" for ROS_INFO, ROS_DEBUG, ...
After tinkering around with the logging, I suddenly get the following warning after many ROS_DEBUG
, ROS_INFO
, ROS_DEBUG_STREAM
, ..., statements.
For example I can run `rosrun turtlesim turtlesim_node' and I get the following output statements (DEBUG enabled in config file):
Warning: recursive print statement has occurred. Throwing out recursive print.
[DEBUG] [1559834260.178750673]: [/turtle1]: pos_x: 5.544445 pos_y: 5.544445 theta: 0.000000
Warning: recursive print statement has occurred. Throwing out recursive print.
[DEBUG] [1559834260.194085344]: [/turtle1]: pos_x: 5.544445 pos_y: 5.544445 theta: 0.000000
Warning: recursive print statement has occurred. Throwing out recursive print.
[DEBUG] [1559834260.210382713]: [/turtle1]: pos_x: 5.544445 pos_y: 5.544445 theta: 0.000000
Warning: recursive print statement has occurred. Throwing out recursive print.
[DEBUG] [1559834260.226757341]: [/turtle1]: pos_x: 5.544445 pos_y: 5.544445 theta: 0.000000
Warning: recursive print statement has occurred. Throwing out recursive print.
[DEBUG] [1559834260.242349101]: [/turtle1]: pos_x: 5.544445 pos_y: 5.544445 theta: 0.000000
Why does
Warning: recursive print statement has occurred. Throwing out recursive print.
always come up and how do I get rid of it again?
System description
Description: Ubuntu 18.04.2 LTS
Release: 18.04
Codename: bionic
Linux jp-XPS-15-9550 4.15.0-51-generic
#55-Ubuntu SMP Wed May 15 14:27:21 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
ROS_DISTRO=melodic
ROS_ETC_DIR=/opt/ros/melodic/etc/ros
ROS_PACKAGE_PATH=/opt/ros/melodic/share
ROS_PYTHON_VERSION=2
ROS_VERSION=1
ROS_ROOT=/opt/ros/melodic/share/ros
ROS_MASTER_URI=http://localhost:11311
ROSLISP_PACKAGE_DIRECTORIES=
Even I did a fresh ROS install with
sudo apt-get purge 'ros-melodic-*' && sudo apt-get install ros-melodic-desktop-full
but it didn't solve the problem as I still get the warning message.
Minimal example
I made a package with a node source code of
#include <ros/ros.h>
int main(int argc, char *argv[]) {
ros::init(argc, argv, "compare");
ros::NodeHandle nh;
ROS_ERROR("Test1");
ROS_DEBUG("Test2");
ROS_INFO("Test3");
return 0;
}
and from this I get when using rosrun ...
the output of:
[DEBUG] [1559834645.265744195]: Adding tcp socket [7] to pollset
[DEBUG] [1559834645.265834503]: UDPROS server listening on port [45530]
[DEBUG] [1559834645.267723312]: Started node [/compare], pid [16880], bound on
ort [38795], tcpros port [57607], using [real] time
Warning: recursive print statement has occurred. Throwing out recursive print.
Warning: recursive print statement has occurred. Throwing out recursive print.
Warning: recursive print statement has occurred. Throwing out recursive print.
[ERROR] [1559834645.268468770]: Test1
Warning: recursive print statement has occurred. Throwing out recursive print.
[DEBUG] [1559834645.268503837]: Test2
Warning: recursive print statement has occurred. Throwing out recursive print.
[ INFO] [1559834645.268532545]: Test3
Warning: recursive print statement has occurred. Throwing out recursive print.
so .. what did you do?
I just selected different options in
rqt_logger_level
and usedrqt_console
to filter and view my messages... no big changes as far as I remember.The warning comes from the rosconsole and warns from printing threads which call each other.