Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OTEL_INTERNAL_LOG_INFO #1407

Merged
merged 3 commits into from
May 19, 2022
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
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