File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ TEST(MixedAttributeMapTest, SetterAndGetter)
149149 attribute_map.SetAttribute (" const char *" , " const char *" );
150150 attribute_map.SetAttribute (" string_view" , opentelemetry::nostd::string_view (" string_view" ));
151151
152- bool array_bool[] = {true , false };
152+ bool array_bool[] = {true , false , true };
153153 uint8_t array_uint8[] = {47 , 48 };
154154 int32_t array_int32[] = {48 , 49 };
155155 int64_t array_int64[] = {49 , 50 };
Original file line number Diff line number Diff line change @@ -105,17 +105,23 @@ class TestBodyLogger : public opentelemetry::logs::Logger
105105 {
106106 if (record)
107107 {
108- last_body_ = static_cast <ReadWriteLogRecord *>(record.get ())-> GetBody ( );
108+ last_body_. reset ( static_cast <ReadWriteLogRecord *>(record.release ()));
109109 }
110110 }
111111
112112 const opentelemetry::common::AttributeValue &GetLastLogRecord () const noexcept
113113 {
114- return last_body_;
114+ if (last_body_)
115+ {
116+ return last_body_->GetBody ();
117+ }
118+
119+ return empty_;
115120 }
116121
117122private:
118- opentelemetry::common::AttributeValue last_body_;
123+ opentelemetry::common::AttributeValue empty_ = nostd::string_view();
124+ nostd::unique_ptr<ReadWriteLogRecord> last_body_;
119125};
120126
121127// Define a basic LoggerProvider class that returns an instance of the logger class defined above
@@ -177,8 +183,8 @@ TEST(LogBody, BodyConversation)
177183 opentelemetry::nostd::holds_alternative<nostd::string_view>(real_logger->GetLastLogRecord ()));
178184 if (opentelemetry::nostd::holds_alternative<const char *>(real_logger->GetLastLogRecord ()))
179185 {
180- ASSERT_EQ (nostd::string_view{" 128" },
181- opentelemetry::nostd::get< const char *>( real_logger->GetLastLogRecord ()));
186+ ASSERT_EQ (nostd::string_view{" 128" }, nostd::string_view{opentelemetry::nostd::get< const char *>(
187+ real_logger->GetLastLogRecord ())} );
182188 }
183189 else
184190 {
You can’t perform that action at this time.
0 commit comments