Skip to content

Commit

Permalink
fix OTEL_INTERNAL_LOG_INFO (#1407)
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb committed May 19, 2022
1 parent a847d0c commit 63803d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 3 additions & 3 deletions sdk/include/opentelemetry/sdk/common/global_log_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(...)
Expand Down
12 changes: 11 additions & 1 deletion sdk/test/common/global_log_handle_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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<CustomLogHandler *>(custom_log_handler.get())->count);
OTEL_INTERNAL_LOG_INFO("Info message");
OTEL_INTERNAL_LOG_WARN("Warning message");
EXPECT_EQ(before_count + 5, static_cast<CustomLogHandler *>(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);
Expand Down

0 comments on commit 63803d1

Please sign in to comment.