Skip to content

Commit 63803d1

Browse files
authored
fix OTEL_INTERNAL_LOG_INFO (open-telemetry#1407)
1 parent a847d0c commit 63803d1

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

sdk/include/opentelemetry/sdk/common/global_log_handler.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,9 @@ OPENTELEMETRY_END_NAMESPACE
236236
# define OTEL_INTERNAL_LOG_INFO_2_ARGS(message, attributes) \
237237
OTEL_INTERNAL_LOG_DISPATCH(opentelemetry::sdk::common::internal_log::LogLevel::Info, message, \
238238
attributes)
239-
# define OTEL_INTERNAL_LOG_INFO_MACRO(...) \
240-
OTEL_INTERNAL_LOG_GET_3RD_ARG(__VA_ARGS__, OTEL_INTERNAL_LOG_ERROR_2_ARGS, \
241-
OTEL_INTERNAL_LOG_ERROR_1_ARGS)
239+
# define OTEL_INTERNAL_LOG_INFO_MACRO(...) \
240+
OTEL_INTERNAL_LOG_GET_3RD_ARG(__VA_ARGS__, OTEL_INTERNAL_LOG_INFO_2_ARGS, \
241+
OTEL_INTERNAL_LOG_INFO_1_ARGS)
242242
# define OTEL_INTERNAL_LOG_INFO(...) OTEL_INTERNAL_LOG_INFO_MACRO(__VA_ARGS__)(__VA_ARGS__)
243243
#else
244244
# define OTEL_INTERNAL_LOG_INFO(...)

sdk/test/common/global_log_handle_test.cc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ class CustomLogHandler : public opentelemetry::sdk::common::internal_log::LogHan
2424
{
2525
EXPECT_EQ(0, strncmp(msg, "Error message", 13));
2626
}
27+
else if (level == opentelemetry::sdk::common::internal_log::LogLevel::Info)
28+
{
29+
EXPECT_EQ(0, strncmp(msg, "Info message", 12));
30+
}
31+
else if (level == opentelemetry::sdk::common::internal_log::LogLevel::Warning)
32+
{
33+
EXPECT_EQ(0, strncmp(msg, "Warning message", 15));
34+
}
2735
++count;
2836
}
2937

@@ -50,7 +58,9 @@ TEST(GlobalLogHandleTest, CustomLogHandler)
5058
opentelemetry::sdk::common::internal_log::LogLevel::Debug);
5159
OTEL_INTERNAL_LOG_ERROR("Error message");
5260
OTEL_INTERNAL_LOG_DEBUG("Debug message. Headers:", attributes);
53-
EXPECT_EQ(before_count + 3, static_cast<CustomLogHandler *>(custom_log_handler.get())->count);
61+
OTEL_INTERNAL_LOG_INFO("Info message");
62+
OTEL_INTERNAL_LOG_WARN("Warning message");
63+
EXPECT_EQ(before_count + 5, static_cast<CustomLogHandler *>(custom_log_handler.get())->count);
5464

5565
opentelemetry::sdk::common::internal_log::GlobalLogHandler::SetLogHandler(backup_log_handle);
5666
opentelemetry::sdk::common::internal_log::GlobalLogHandler::SetLogLevel(backup_log_level);

0 commit comments

Comments
 (0)