0
$\begingroup$

Rosanswers logo

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?


Originally posted by Jeffrey Kane Johnson on ROS Answers with karma: 452 on 2020-09-14

Post score: 4

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by Josh Whitley with karma: 1766 on 2020-09-15

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by Jeffrey Kane Johnson on 2020-09-16:
Perfect, thanks!

Comment by dannee on 2022-09-19:
If anyone is looking for the python answer, it can be called with: rclpy.logging.get_logger(name)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.