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

[ros 2] How to create a non-node logger?

asked 2020-09-14 09:00:44 -0500

In the documentation it says:

Non-node loggers can also be created that use a specific name.

Is there an example or tutorial somewhere that shows how to do this?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-09-15 23:04:48 -0500

Josh Whitley gravatar image

Hey, Jeff. I actually stumbled across the answer to this not too long ago. When you use logging macros in ROS2, the first argument is an rclcpp::Logger which you would normally get from calling get_logger() on an rclcpp::Node. However, the rclcpp namespace also provides a get_logger() function which can be used to generate an rclcpp::Logger without a node instance by just giving it a name. I believe the only difference between this type of rclcpp::Logger instance and the one you would get from a node is the logger maintaining a reference to the node and changing its name if the node name changes.

edit flag offensive delete link more


Perfect, thanks!

Jeffrey Kane Johnson gravatar image Jeffrey Kane Johnson  ( 2020-09-16 06:15:25 -0500 )edit

If anyone is looking for the python answer, it can be called with: rclpy.logging.get_logger(name)

dannee gravatar image dannee  ( 2022-09-19 01:36:51 -0500 )edit

Question Tools



Asked: 2020-09-14 09:00:44 -0500

Seen: 781 times

Last updated: Sep 15 '20