From e4f84140cb497df51be67c86f8ed69946a9848bc Mon Sep 17 00:00:00 2001 From: danielsanchezaran Date: Fri, 29 Nov 2024 17:20:28 +0900 Subject: [PATCH] feat(universe_utils): add extra info to time keeper warning (#9484) add extra info to time keeper warning Signed-off-by: Daniel Sanchez --- .github/{CODEOWNERS => _CODEOWNERS} | 0 .../autoware_universe_utils/src/system/time_keeper.cpp | 8 +++++--- .../test/src/system/test_time_keeper.cpp | 10 +++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) rename .github/{CODEOWNERS => _CODEOWNERS} (100%) diff --git a/.github/CODEOWNERS b/.github/_CODEOWNERS similarity index 100% rename from .github/CODEOWNERS rename to .github/_CODEOWNERS diff --git a/common/autoware_universe_utils/src/system/time_keeper.cpp b/common/autoware_universe_utils/src/system/time_keeper.cpp index 8c715c5ccd7e3..b6e82cbd2f58a 100644 --- a/common/autoware_universe_utils/src/system/time_keeper.cpp +++ b/common/autoware_universe_utils/src/system/time_keeper.cpp @@ -20,6 +20,7 @@ #include #include +#include namespace autoware::universe_utils { @@ -135,9 +136,10 @@ void TimeKeeper::start_track(const std::string & func_name) root_node_thread_id_ = std::this_thread::get_id(); } else { if (root_node_thread_id_ != std::this_thread::get_id()) { - RCLCPP_WARN( - rclcpp::get_logger("TimeKeeper"), - "TimeKeeper::start_track() is called from a different thread. Ignoring the call."); + const auto warning_msg = fmt::format( + "TimeKeeper::start_track({}) is called from a different thread. Ignoring the call.", + func_name); + RCLCPP_WARN(rclcpp::get_logger("TimeKeeper"), "%s", warning_msg.c_str()); return; } current_time_node_ = current_time_node_->add_child(func_name); diff --git a/common/autoware_universe_utils/test/src/system/test_time_keeper.cpp b/common/autoware_universe_utils/test/src/system/test_time_keeper.cpp index 0540fa8a283ad..ffefaed316b19 100644 --- a/common/autoware_universe_utils/test/src/system/test_time_keeper.cpp +++ b/common/autoware_universe_utils/test/src/system/test_time_keeper.cpp @@ -86,7 +86,11 @@ TEST_F(TimeKeeperTest, MultiThreadWarning) t.join(); std::string err = testing::internal::GetCapturedStderr(); - EXPECT_TRUE( - err.find("TimeKeeper::start_track() is called from a different thread. Ignoring the call.") != - std::string::npos); + const bool error_found = err.find( + "TimeKeeper::start_track(MainFunction) is called from a different " + "thread. Ignoring the call.") != std::string::npos || + err.find( + "TimeKeeper::start_track(ThreadFunction) is called from a different " + "thread. Ignoring the call.") != std::string::npos; + EXPECT_TRUE(error_found); }