Skip to content

Hand-code logging_macros.h#502

Merged
clalancette merged 1 commit intorollingfrom
clalancette/open-coded-logging-macros
Jul 1, 2025
Merged

Hand-code logging_macros.h#502
clalancette merged 1 commit intorollingfrom
clalancette/open-coded-logging-macros

Conversation

@clalancette
Copy link
Copy Markdown
Contributor

Description

In my opinion, this makes it far more readable for humans, and thus easier to update/maintain in the future. This ends up removing ~500 lines of python code, empy templates, and associated machinery, plus 1500 lines of generated code. This also has the the nice side effect of making it so that rosdoc2 will generate the documentation for all of these macros.

Is this user-facing behavior change?

No (API remains the same, only the implementation is different)

Did you use Generative AI?

No.

Additional Information

I've compiled all of the ROS 2 core with this in place, and it seems happy enough.

@mjcarroll
Copy link
Copy Markdown
Member

I like the additional benefit of removing dependence on python here for such a simple action.

I'm going to add this to the PMC agenda for this week, thanks.

Copy link
Copy Markdown
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, IMO this is good enhancement for maintainability. besides less dependency, this also helps me to walk through the source code symbols without building the em files 👍

Copy link
Copy Markdown
Contributor

@sloretz sloretz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a great spot to not generate code. As a user I've gone looking for these macros in the past, and it took me extra time to figure out what macros are being generated.

@christophebedard
Copy link
Copy Markdown
Member

What about the rclcpp logging header? That one is even more user-facing. https://github.com/ros2/rclcpp/blob/rolling/rclcpp/resource/logging.hpp.em

@clalancette
Copy link
Copy Markdown
Contributor Author

What about the rclcpp logging header? That one is even more user-facing. https://github.com/ros2/rclcpp/blob/rolling/rclcpp/resource/logging.hpp.em

That's a reasonable followup, yeah. That one should be a bit easier; it doesn't too much of its own machinery (mostly wrapping of these macros).

@fujitatomoya
Copy link
Copy Markdown
Collaborator

Pulls: #502
Gist: https://gist.githubusercontent.com/fujitatomoya/3041e666744421d177117d1b430a8b02/raw/e5879c0de8d7e980ea9f6af4e9ac43c12053c797/ros2.repos
BUILD args: --packages-above-and-dependencies rcutils
TEST args: --packages-above rcutils
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/16195

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@clalancette
Copy link
Copy Markdown
Contributor Author

One other thing I should mention; I don't think this should be backported to stable distributions. While it doesn't change the user-facing macros, there are technically some macros (like RCUTILS_LOG_CONDITION_EMPTY) that we are removing here, and that users could have relied on. I don't think this will be widespread, but I do think we should probably just keep this on rolling.

@clalancette
Copy link
Copy Markdown
Contributor Author

Ah. So it looks like we actually have to do rclcpp right now, because it depends on this (I didn't see it locally because I didn't rebuild from scratch, and I must have had the python code still around in my install space). I'll go ahead and do rclcpp first, then we can revisit this.

In my opinion, this makes it far more readable for
humans, and thus easier to update/maintain in the future.
This ends up removing ~500 lines of python code, empy templates,
and associated machinery, plus 1500 lines of generated code.
This also has the the nice side effect of making it
so that rosdoc2 will generate the documentation for all of
these macros.

Signed-off-by: Chris Lalancette <clalancette@gmail.com>
@clalancette clalancette force-pushed the clalancette/open-coded-logging-macros branch from faecb49 to c1ea754 Compare June 11, 2025 13:55
@clalancette
Copy link
Copy Markdown
Contributor Author

Ah. So it looks like we actually have to do rclcpp right now, because it depends on this (I didn't see it locally because I didn't rebuild from scratch, and I must have had the python code still around in my install space). I'll go ahead and do rclcpp first, then we can revisit this.

All right, I've updated this PR and opened up ros2/rclcpp#2870 , which does the same for rclcpp.

@ros-discourse
Copy link
Copy Markdown

This pull request has been mentioned on ROS Discourse. There might be relevant details there:

https://discourse.ros.org/t/ros-pmc-minutes-for-june-10-2025/44219/1

@clalancette
Copy link
Copy Markdown
Contributor Author

clalancette commented Jun 11, 2025

Pulls: #502, ros2/rclcpp#2870
Gist: https://gist.githubusercontent.com/clalancette/b484add6961112574c7cdf4a320ee81f/raw/390bbce57b63eafdd919881fab531023966308b7/ros2.repos
BUILD args:
TEST args:
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/16204

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@ros-discourse
Copy link
Copy Markdown

This pull request has been mentioned on Open Robotics Discourse. There might be relevant details there:

https://discourse.ros.org/t/change-to-the-implementation-of-the-rcutils-log-and-rclcpp-logging-macros/44443/1

@clalancette
Copy link
Copy Markdown
Contributor Author

CI is clean here, and there were no concerns in the discourse thread, so I'm going ahead and merging in this one and ros2/rclcpp#2870

@clalancette clalancette merged commit d6689e0 into rolling Jul 1, 2025
3 checks passed
@clalancette clalancette deleted the clalancette/open-coded-logging-macros branch July 1, 2025 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants