Skip to content

rclcpp logging still uses fprintf all over the place.#439

Merged
dhood merged 2 commits intoros2:masterfrom
clearpathrobotics:issue-438
Feb 24, 2018
Merged

rclcpp logging still uses fprintf all over the place.#439
dhood merged 2 commits intoros2:masterfrom
clearpathrobotics:issue-438

Conversation

@guillaumeautran
Copy link
Copy Markdown
Contributor

Remove all printf log lines and replace with RCLUTILS_LOG_XXX macros.

Issue: #438

Copy link
Copy Markdown
Member

@mikaelarguedas mikaelarguedas left a comment

Choose a reason for hiding this comment

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

Thanks @guillaumeautran for the patch.
This looks good to me except some style comments that will make out linter tests fail. You can run the tests of a given package by using ament test --only <PKG_NAME>

#include "rmw/error_handling.h"
#include "rmw/rmw.h"

#include "rcutils/logging_macros.h"
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.

Nit: Header included twice?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed


#include "rcutils/logging_macros.h"


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.

Same here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed


#include "rcutils/logging_macros.h"


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.

single vertical whitespace

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

fprintf(stderr,
"[rclcpp::error] failed to trigger guard condition: %s\n", rcl_get_error_string_safe());
RCUTILS_LOG_ERROR_NAMED(
"rclcpp",
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.

Nit: this should be indented

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

#include "rmw/error_handling.h"
#include "rmw/rmw.h"

#include "rcutils/logging_macros.h"
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.

Nit: we encourage the use of single vertical space

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

@guillaumeautran
Copy link
Copy Markdown
Contributor Author

@mikaelarguedas I'm having problem running the tests on my system due to some gmock cmake non-sense. Any idea?

-- Found gmock sources under '/usr/src/gmock': C++ tests using 'Google Mock' will be built
CMake Error at /usr/src/gtest/cmake/internal_utils.cmake:130 (add_library):
  add_library cannot create target "gtest" because another target with the
  same name already exists.  The existing target is a static library created
  in source directory "/usr/src/gtest".  See documentation for policy CMP0002
  for more details.
Call Stack (most recent call first):
  /usr/src/gtest/cmake/internal_utils.cmake:153 (cxx_library_with_type)
  /usr/src/gtest/CMakeLists.txt:70 (cxx_library)


CMake Error at /usr/src/gtest/cmake/internal_utils.cmake:130 (add_library):
  add_library cannot create target "gtest_main" because another target with
  the same name already exists.  The existing target is a static library
  created in source directory "/usr/src/gtest".  See documentation for policy
  CMP0002 for more details.
Call Stack (most recent call first):
  /usr/src/gtest/cmake/internal_utils.cmake:153 (cxx_library_with_type)
  /usr/src/gtest/CMakeLists.txt:71 (cxx_library)


CMake Error at /usr/src/gtest/CMakeLists.txt:72 (target_link_libraries):
  Attempt to add link library "gtest" to target "gtest_main" which is not
  built in this directory.

Remove all printf log lines and replace with RCLUTILS_LOG_XXX macros.

Issue: ros2#438
@dhood dhood added the in review Waiting for review (Kanban column) label Feb 20, 2018
@wjwwood
Copy link
Copy Markdown
Member

wjwwood commented Feb 22, 2018

@guillaumeautran please include more context for that error, ideally all of the build output in a gist.github.com or something.

@guillaumeautran
Copy link
Copy Markdown
Contributor Author

Ok, I sorted out my issue. Caused by: https://cmake.org/cmake/help/v3.0/policy/CMP0002.html since my cmake version is 3.5.1
But I took care of it and am now able to address the review comments. Patch coming up soon.

@dhood
Copy link
Copy Markdown
Member

dhood commented Feb 23, 2018

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@dhood
Copy link
Copy Markdown
Member

dhood commented Feb 24, 2018

This looks good thanks @guillaumeautran

I was going to suggest the use of ROS_PACKAGE_NAME for the logger name but it's provided by ament_cmake_ros which isn't be used by this package yet (#444)

@dhood dhood merged commit 0e79842 into ros2:master Feb 24, 2018
@dhood dhood removed the in review Waiting for review (Kanban column) label Feb 24, 2018
nnmm pushed a commit to ApexAI/rclcpp that referenced this pull request Jul 9, 2022
Signed-off-by: cevans87 <c.d.evans87@gmail.com>
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.

4 participants