Comprehensive code walkthrough of the rclcpp / rcutils / rcl logging subsystems

Dear all,

In the context of looking into implementing a small realtime loop using core ROS 2 functionality (not sure yet if that is a realistic endeavor given current ROS 2 implementation, but anyway), I had the following simple question:

Is it OK to include log macro calls in realtime code, so you can log (non-realtime) during debugging but disable it through the loglevel for normal operation?

I don’t think many people readily know the answer. :slight_smile:
So I decided to look through the code and write down my findings.

The result is a comprehensive code walkthrough through the rclcpp / rcutils / rcl logging subsystems.


I think it can be of value to anyone wanting a thorough understanding of the current ROS 2 logging, as well as maybe be an gentle introduction into digging through ROS 2 core.

I’d be grateful for feedback, especially concerning the assumptions and questions in the text, wrt. realtime-compliance.

Hi there,
Nice writeup! I’ll point out that some of this information is in About logging and logger configuration — ROS 2 Documentation: Rolling documentation , but it is not focused on real-time. Nevertheless, if there are things you think could be added or clarified on that page, please feel free to open a PR and I’d be happy to review.

@clalancette Indeed. My document is rather targeted at understanding the code, whereas the official docs at using it.

Re. adapting the docs: in my ideal world, somebody reads my text, thinks “Hey, I can also contribute!” and takes initiative to adapt the docs where needed. I would do it, but I’ve already rather blown my time budget on this. :slight_smile:

But overall, the current logging documentation is ok. My only remarks are:

  • Default log dir is $ROS_HOME/log, not $ROS_HOME/.log
  • Rosout logging should be described more in detail, e.g. that this only works for node loggers and not for named loggers etc.
  • Add a link to this document :wink:

Thanks for your great documentation of the code-walk-through. If you are interested in a real-time Executor itself, you are very welcome to join one of the real-time working group meetings. Your work is very valuable. We are planning to do a similar code-walk-through regarding real-time behavior of the rclcpp-Executor.

1 Like