Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions rclcpp/include/rclcpp/logging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@
* \copydoc RCLCPP_LOG_STREAM_FUNCTION
*/
#define RCLCPP_DEBUG_STREAM_FUNCTION(logger, function, stream_arg) \
RCLCPP_LOG_STREAM_FUNCTION(RCUTILS_LOG_SEVERITY_DEBUG, logger, function, stream_args)
RCLCPP_LOG_STREAM_FUNCTION(RCUTILS_LOG_SEVERITY_DEBUG, logger, function, stream_arg)

/**
* \def RCLCPP_DEBUG_STREAM_SKIPFIRST
Expand Down Expand Up @@ -756,7 +756,7 @@
* \copydoc RCLCPP_LOG_STREAM_FUNCTION
*/
#define RCLCPP_INFO_STREAM_FUNCTION(logger, function, stream_arg) \
RCLCPP_LOG_STREAM_FUNCTION(RCUTILS_LOG_SEVERITY_INFO, logger, function, stream_args)
RCLCPP_LOG_STREAM_FUNCTION(RCUTILS_LOG_SEVERITY_INFO, logger, function, stream_arg)

/**
* \def RCLCPP_INFO_STREAM_SKIPFIRST
Expand Down Expand Up @@ -952,7 +952,7 @@
* \copydoc RCLCPP_LOG_STREAM_FUNCTION
*/
#define RCLCPP_WARN_STREAM_FUNCTION(logger, function, stream_arg) \
RCLCPP_LOG_STREAM_FUNCTION(RCUTILS_LOG_SEVERITY_WARN, logger, function, stream_args)
RCLCPP_LOG_STREAM_FUNCTION(RCUTILS_LOG_SEVERITY_WARN, logger, function, stream_arg)

/**
* \def RCLCPP_WARN_STREAM_SKIPFIRST
Expand Down Expand Up @@ -1148,7 +1148,7 @@
* \copydoc RCLCPP_LOG_STREAM_FUNCTION
*/
#define RCLCPP_ERROR_STREAM_FUNCTION(logger, function, stream_arg) \
RCLCPP_LOG_STREAM_FUNCTION(RCUTILS_LOG_SEVERITY_ERROR, logger, function, stream_args)
RCLCPP_LOG_STREAM_FUNCTION(RCUTILS_LOG_SEVERITY_ERROR, logger, function, stream_arg)

/**
* \def RCLCPP_ERROR_STREAM_SKIPFIRST
Expand Down Expand Up @@ -1346,7 +1346,7 @@
* \copydoc RCLCPP_LOG_STREAM_FUNCTION
*/
#define RCLCPP_FATAL_STREAM_FUNCTION(logger, function, stream_arg) \
RCLCPP_LOG_STREAM_FUNCTION(RCUTILS_LOG_SEVERITY_FATAL, logger, function, stream_args)
RCLCPP_LOG_STREAM_FUNCTION(RCUTILS_LOG_SEVERITY_FATAL, logger, function, stream_arg)

/**
* \def RCLCPP_FATAL_STREAM_SKIPFIRST
Expand Down
28 changes: 28 additions & 0 deletions rclcpp/test/rclcpp/test_logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,34 @@ TEST_F(TestLoggingMacros, test_logging_function) {
EXPECT_EQ("message 5", g_last_log_event.message);
}

TEST_F(TestLoggingMacros, test_logging_stream_function) {
for (int i : {1, 2, 3, 4, 5, 6}) {
g_counter = i;
RCLCPP_DEBUG_STREAM_FUNCTION(g_logger, &mod3, "debug message " << i);
RCLCPP_INFO_STREAM_FUNCTION(g_logger, &mod3, "info message " << i);
RCLCPP_WARN_STREAM_FUNCTION(g_logger, &mod3, "warn message " << i);
RCLCPP_ERROR_STREAM_FUNCTION(g_logger, &mod3, "error message " << i);
RCLCPP_FATAL_STREAM_FUNCTION(g_logger, &mod3, "fatal message " << i);
}
EXPECT_EQ(20u, g_log_calls);
EXPECT_EQ(RCUTILS_LOG_SEVERITY_FATAL, g_last_log_event.level);
EXPECT_EQ("fatal message 5", g_last_log_event.message);
}

TEST_F(TestLoggingMacros, test_logging_format_function) {
for (int i : {1, 2, 3, 4, 5, 6}) {
g_counter = i;
RCLCPP_DEBUG_FMT_FUNCTION(g_logger, &mod3, "debug message {}", i);
RCLCPP_INFO_FMT_FUNCTION(g_logger, &mod3, "info message {}", i);
RCLCPP_WARN_FMT_FUNCTION(g_logger, &mod3, "warn message {}", i);
RCLCPP_ERROR_FMT_FUNCTION(g_logger, &mod3, "error message {}", i);
RCLCPP_FATAL_FMT_FUNCTION(g_logger, &mod3, "fatal message {}", i);
}
EXPECT_EQ(20u, g_log_calls);
EXPECT_EQ(RCUTILS_LOG_SEVERITY_FATAL, g_last_log_event.level);
EXPECT_EQ("fatal message 5", g_last_log_event.message);
}

TEST_F(TestLoggingMacros, test_logging_skipfirst) {
for (uint32_t i : {1, 2, 3, 4, 5}) {
RCLCPP_WARN_SKIPFIRST(g_logger, "message %u", i);
Expand Down
Loading