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

Revision history [back]

click to hide/show revision 1
initial version

It does matter, however there's no generic right option for all cases. Each one could be better in different situations.

If you are only planning to use the logger in that one function one time or only in places where the logger is easily accessible in the current context it would be fine to use Option 3

If you're going to use the logger in many different methods, call methods from contexts without the logger conveniently accessible, or potentially callbacks etc you'll probably want to escalate to option 2 where the logger does not need to be passed to all elements of the API.

And if you're going to be using other features of the Node inside the class you could consider option 1. But if you just want the logger functionality I'd recommend only passing what you need.