Change to the implementation of the RCUTILS_LOG_* and RCLCPP_* logging macros

TL;DR; if your Rolling project is using the RCUTILS_LOG_* and RCLCPP_* macros for ROS 2 logging in the standard way, no change will be required. If you are using the internal implementation details of those macros (like RCUTILS_LOG_CONDITION_ONCE_BEFORE), then read on for changes that will affect you.


In the soon-to-be merged PRs Hand-code logging_macros.h by clalancette · Pull Request #502 · ros2/rcutils · GitHub and Hand-code logging.hpp by clalancette · Pull Request #2870 · ros2/rclcpp · GitHub , the way that the logging macros are implemented has changed. In particular, we switched from using empy templates to hand-coding them. This has a number of benefits:

  1. The documentation for the logging macros will now be automatically generated into rcutils — rcutils: Rolling 7.0.1 documentation and rclcpp — rclcpp: Rolling 30.0.0 documentation
  2. We can remove the empy dependency from rcutils, and eventually rclcpp (it is still there for unrelated reasons).
  3. The macros are far more maintainable and human-understandable this way. The bulk of the implementation is in a few “implementation” macros, and the user-facing macros just use these.

One downside to this change is that these are all C macros, and hence the “implementation details” of the old system will be removed. If your Rolling package is using the standard macros like RCUTILS_LOG_DEBUG or RCLCPP_DEBUG, no change at all will be required to your package. However, if your package is using any of the following macros/typedefs, it will have to be updated:

  • RCUTILS_CAST_DURATION
  • RCUTILS_LOG_COND_NAMED
  • RCUTILS_LOG_CONDITION_EMPTY
  • RCUTILS_LOG_CONDITION_ONCE_BEFORE
  • RCUTILS_LOG_CONDITION_ONCE_AFTER
  • RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE
  • RCUTILS_LOG_CONDITION_EXPRESSION_AFTER
  • RCUTILS_LOG_CONDITION_FUNCTION_BEFORE
  • RCUTILS_LOG_CONDITION_FUNCTION_AFTER
  • RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE
  • RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER
  • RCUTILS_LOG_CONDITION_THROTTLE_BEFORE
  • RCUTILS_LOG_CONDITION_THROTTLE_AFTER
  • RCLCPP_FIRST_ARG
  • RCLCPP_ALL_BUT_FIRST_ARGS
  • RclLogFilter

(to be clear, I looked at all of the packages currently released into rosdistro/rolling/distribution.yaml at master · ros/rosdistro · GitHub , and not a single one used any of these macros)

Note that we will not be backporting this to stable distributions; this change will only affect Rolling (and eventually Lyrical).

If you have questions, comments, or concerns about this change, please let us know in this thread.

5 Likes

There have been no concerns here, so I’m going to go ahead and merge in the PRs mentioned here. I’ll also (shortly) do a release so these will be available in the testing repository. If you run into any issues surrounding this macros, please let us know in this thread.

1 Like