Skip to content

Document changes to rclcpp's logging macros (#949)#1220

Merged
clalancette merged 1 commit intoros2:rollingfrom
audrow:audrow/reintroduce-logging-change
Mar 11, 2021
Merged

Document changes to rclcpp's logging macros (#949)#1220
clalancette merged 1 commit intoros2:rollingfrom
audrow:audrow/reintroduce-logging-change

Conversation

@audrow
Copy link
Copy Markdown
Member

@audrow audrow commented Mar 11, 2021

I noticed that this change wasn't brought into the rolling branch from master after #949.

It might be the case that other changes were omitted in moving off of master.

* Add changes to rclcpp's logging macros

Signed-off-by: Audrow Nash <audrow.nash@gmail.com>

* Apply suggestions from code review

Signed-off-by: Audrow Nash <audrow.nash@gmail.com>

Co-authored-by: Chris Lalancette <clalancette@openrobotics.org>

* Fix syntax error by adding an escape character after ticks

Signed-off-by: Audrow Nash <audrow.nash@gmail.com>

* Update examples

Signed-off-by: Audrow Nash <audrow.nash@gmail.com>

* Make string examples clearer

Signed-off-by: Audrow Nash <audrow.nash@gmail.com>

* Replace second string example with a note

Signed-off-by: Audrow Nash <audrow.nash@gmail.com>

Co-authored-by: Chris Lalancette <clalancette@openrobotics.org>
@audrow audrow requested a review from clalancette March 11, 2021 04:43
@audrow audrow self-assigned this Mar 11, 2021
Copy link
Copy Markdown
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

@audrow Apologies, somehow this got missed in the conversion from the master -> rolling branch.

@clalancette clalancette merged commit 15eb141 into ros2:rolling Mar 11, 2021
@clalancette
Copy link
Copy Markdown
Contributor

@Mergifyio backport foxy dashing

mergify bot pushed a commit that referenced this pull request Mar 11, 2021
* Add changes to rclcpp's logging macros

Signed-off-by: Audrow Nash <audrow.nash@gmail.com>
Co-authored-by: Chris Lalancette <clalancette@openrobotics.org>
(cherry picked from commit 15eb141)
mergify bot pushed a commit that referenced this pull request Mar 11, 2021
* Add changes to rclcpp's logging macros

Signed-off-by: Audrow Nash <audrow.nash@gmail.com>
Co-authored-by: Chris Lalancette <clalancette@openrobotics.org>
(cherry picked from commit 15eb141)
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Mar 11, 2021

Command backport foxy dashing: success

Backports have been created

clalancette pushed a commit that referenced this pull request Mar 11, 2021
* Add changes to rclcpp's logging macros

Signed-off-by: Audrow Nash <audrow.nash@gmail.com>
Co-authored-by: Chris Lalancette <clalancette@openrobotics.org>
(cherry picked from commit 15eb141)

Co-authored-by: Audrow Nash <audrow.nash@gmail.com>
clalancette pushed a commit that referenced this pull request Mar 11, 2021
* Add changes to rclcpp's logging macros

Signed-off-by: Audrow Nash <audrow.nash@gmail.com>
Co-authored-by: Chris Lalancette <clalancette@openrobotics.org>
(cherry picked from commit 15eb141)

Co-authored-by: Audrow Nash <audrow.nash@gmail.com>
Comment on lines +185 to +186
std::string my_std_string = "Foo";
RCLCPP_DEBUG(get_logger(), "%s", my_std_string.c_str());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I hit this issue in some packages, and while updating I found that I could put the c-string directly as the first argument, e.g.

std::string my_std_string = "Foo";
RCLCPP_DEBUG(get_logger(), my_std_string.c_str());

Is this expected, or should I not do this for security reasons? If it's the latter, then is there a way we can enforce this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You should not do it for security reasons. If you enable -Wformat=2 on your package, you'll get a warning about that line of code.

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.

3 participants