Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make LifecycleNode logs publish to rosout #2221

Closed
tonynajjar opened this issue Jun 22, 2023 · 3 comments · Fixed by #2233
Closed

Make LifecycleNode logs publish to rosout #2221

tonynajjar opened this issue Jun 22, 2023 · 3 comments · Fixed by #2233
Assignees
Labels
bug Something isn't working

Comments

@tonynajjar
Copy link
Contributor


Feature request

Feature description

The logs inside the LifecycleNode are not published to rosout making hard to debug issues when relying on rosout-reading tools (e.g foxglove). I guess the reason is because the rcutil logging macros are used
instead of the rclcpp logging macros?

What would be the easiest way to enable publishing those logs to rosout? Thanks

Implementation considerations

@clalancette clalancette self-assigned this Jun 29, 2023
@clalancette
Copy link
Contributor

So the logging subsystem uses a dependency-injection type of model. In particular, what happens is that the rcutils_logging APIs allow the registration of an arbitrary number of callbacks, and when a log message comes in, it calls each of those callbacks in turn. By default, rcutils only registers a callback to print to the screen. But the rclcpp layer than registers additional callbacks to send the logs to disk and to /rosout. Thus, no matter whether you are calling the RCUTILS log macros or the RCLCPP ones, they should in theory go out to all registered places.

But I can indeed confirm that this is not happening with the RCUTILS macros, either with the LifecycleNode or with a regular Node, for that matter. Something about the logging subsystem isn't working how I expect.

@clalancette clalancette added the bug Something isn't working label Jun 30, 2023
@clalancette
Copy link
Contributor

So the logging subsystem uses a dependency-injection type of model. In particular, what happens is that the rcutils_logging APIs allow the registration of an arbitrary number of callbacks, and when a log message comes in, it calls each of those callbacks in turn.

Actually, after looking at this further, this is wrong. rcutils only has room for a single callback. The multiple callback solution is implemented in the rcl layer, so it will indeed only work if you are using the RCLCPP macros. That seems like something of a design problem, and it would be nice to move that into the rcutils layer. But for now, the easier solution is to change the Lifecycle code to just use the RCLCPP macros. See #2233 for the fix.

@tonynajjar
Copy link
Contributor Author

tonynajjar commented Jul 6, 2023

Thanks a lot for the quick fix! When I find some time, probably early next week, I'll try to backport the fix to Humble locally and test it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants