From f11fcaaa4a3cbd608431f062cc0f3133dbd1c001 Mon Sep 17 00:00:00 2001 From: Lucas Wendland <82680922+CursedRock17@users.noreply.github.com> Date: Wed, 23 Aug 2023 21:41:44 -0400 Subject: [PATCH] Adding duplicate node information (#1088) Signed-off-by: CursedRock17 Co-authored-by: Chris Lalancette --- rcl/src/rcl/logging_rosout.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/rcl/src/rcl/logging_rosout.c b/rcl/src/rcl/logging_rosout.c index 5f0458d55..eec76c17f 100644 --- a/rcl/src/rcl/logging_rosout.c +++ b/rcl/src/rcl/logging_rosout.c @@ -12,9 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "rcl/logging_rosout.h" + #include "rcl/allocator.h" #include "rcl/error_handling.h" -#include "rcl/logging_rosout.h" #include "rcl/node.h" #include "rcl/publisher.h" #include "rcl/time.h" @@ -250,13 +251,20 @@ rcl_ret_t rcl_logging_rosout_init_publisher_for_node(rcl_node_t * node) if (rcutils_hash_map_key_exists(&__logger_map, &logger_name)) { // @TODO(nburek) Update behavior to either enforce unique names or work with non-unique // names based on the outcome here: https://github.com/ros2/design/issues/187 + const char * node_name = rcl_node_get_name(node); + if (NULL == node_name) { + node_name = "unknown node"; + } + RCUTILS_LOG_WARN_NAMED( "rcl.logging_rosout", - "Publisher already registered for provided node name. If this is due to multiple nodes " - "with the same name then all logs for that logger name will go out over the existing " - "publisher. As soon as any node with that name is destructed it will unregister the " - "publisher, preventing any further logs for that name from being published on the rosout " - "topic."); + "Publisher already registered for node name: '%s'. If this is due to multiple nodes " + "with the same name then all logs for the logger named '%s' will go out over " + "the existing publisher. As soon as any node with that name is destructed " + "it will unregister the publisher, preventing any further logs for that name from " + "being published on the rosout topic.", + node_name, + logger_name); return RCL_RET_OK; }