If you want to discuss an effort to add the missing operators, like stream, throttle (throttle is there btw), etc…, that’s fine, but please move it to an issue on GitHub as soon as you can. For the questions about why and how, that’s better left to answers.ros.org.
Make sure you consider Support - ROS Wiki when posting something like this.
What you didn’t realize is that there was an implicit first argument there which was the node singleton from ROS 1. As previously discussed, ROS 2 doesn’t have that, so to emulate that macro from ROS 1 you must provide the missing first argument. We cannot guess it for you.
We intentionally require the logger name because otherwise you aren’t forced to consider what it will look like on the console. If you really want to have no logger name, then you can use ""
, but I don’t recommend that.
Also, you can store logger objects statically and globally, so you can just do something like static const rclcpp::Logger g_logger = rclcpp::get_logger("whatever");
in your cpp file, and then everywhere you want to log you can do RCLCPP_WARN(g_logger, "...");
.
But most people don’t have which function or file a log message came from enabled when logging. Imagine you had several nodes, all in the same process, which each call this function, but only one of them produces a log message. How do you know which one it came from?
In ROS 1, the node which produced the warning was implicitly included in calls to things like ROS_WARN
, so that wasn’t a problem.
In ROS 2, since nodes are not globally accessible and because there isn’t just one per process, you need to tell us which node it’s a part of when you make a logging call. You can either pass a node through you API’s or an instance of the rclcpp::Logger
object (just a struct
wrapping a std::string
). As @nburek mentioned you can get a logger from a node which includes its full name (include a namespace) with node->get_logger()
.