From 63803d10c6ec2b8f5315856fe258f63d386aca3b Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Wed, 18 May 2022 18:56:21 -0700 Subject: [PATCH] fix OTEL_INTERNAL_LOG_INFO (#1407) --- .../opentelemetry/sdk/common/global_log_handler.h | 6 +++--- sdk/test/common/global_log_handle_test.cc | 12 +++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/common/global_log_handler.h b/sdk/include/opentelemetry/sdk/common/global_log_handler.h index 06bbd30f7d..612d21eca5 100644 --- a/sdk/include/opentelemetry/sdk/common/global_log_handler.h +++ b/sdk/include/opentelemetry/sdk/common/global_log_handler.h @@ -236,9 +236,9 @@ OPENTELEMETRY_END_NAMESPACE # define OTEL_INTERNAL_LOG_INFO_2_ARGS(message, attributes) \ OTEL_INTERNAL_LOG_DISPATCH(opentelemetry::sdk::common::internal_log::LogLevel::Info, message, \ attributes) -# define OTEL_INTERNAL_LOG_INFO_MACRO(...) \ - OTEL_INTERNAL_LOG_GET_3RD_ARG(__VA_ARGS__, OTEL_INTERNAL_LOG_ERROR_2_ARGS, \ - OTEL_INTERNAL_LOG_ERROR_1_ARGS) +# define OTEL_INTERNAL_LOG_INFO_MACRO(...) \ + OTEL_INTERNAL_LOG_GET_3RD_ARG(__VA_ARGS__, OTEL_INTERNAL_LOG_INFO_2_ARGS, \ + OTEL_INTERNAL_LOG_INFO_1_ARGS) # define OTEL_INTERNAL_LOG_INFO(...) OTEL_INTERNAL_LOG_INFO_MACRO(__VA_ARGS__)(__VA_ARGS__) #else # define OTEL_INTERNAL_LOG_INFO(...) diff --git a/sdk/test/common/global_log_handle_test.cc b/sdk/test/common/global_log_handle_test.cc index 9c24b0234e..a38bdc8728 100644 --- a/sdk/test/common/global_log_handle_test.cc +++ b/sdk/test/common/global_log_handle_test.cc @@ -24,6 +24,14 @@ class CustomLogHandler : public opentelemetry::sdk::common::internal_log::LogHan { EXPECT_EQ(0, strncmp(msg, "Error message", 13)); } + else if (level == opentelemetry::sdk::common::internal_log::LogLevel::Info) + { + EXPECT_EQ(0, strncmp(msg, "Info message", 12)); + } + else if (level == opentelemetry::sdk::common::internal_log::LogLevel::Warning) + { + EXPECT_EQ(0, strncmp(msg, "Warning message", 15)); + } ++count; } @@ -50,7 +58,9 @@ TEST(GlobalLogHandleTest, CustomLogHandler) opentelemetry::sdk::common::internal_log::LogLevel::Debug); OTEL_INTERNAL_LOG_ERROR("Error message"); OTEL_INTERNAL_LOG_DEBUG("Debug message. Headers:", attributes); - EXPECT_EQ(before_count + 3, static_cast(custom_log_handler.get())->count); + OTEL_INTERNAL_LOG_INFO("Info message"); + OTEL_INTERNAL_LOG_WARN("Warning message"); + EXPECT_EQ(before_count + 5, static_cast(custom_log_handler.get())->count); opentelemetry::sdk::common::internal_log::GlobalLogHandler::SetLogHandler(backup_log_handle); opentelemetry::sdk::common::internal_log::GlobalLogHandler::SetLogLevel(backup_log_level);