From 94e5ef8fea8b061ce9384614336cc0927d67a7a3 Mon Sep 17 00:00:00 2001 From: Karen Xu Date: Mon, 7 Dec 2020 02:56:10 -0500 Subject: [PATCH] Temporary rename (can drop this commit if #422 gets merged) --- api/include/opentelemetry/logs/log_record.h | 27 ++++++++++++--------- exporters/ostream/test/ostream_log_test.cc | 4 +-- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/api/include/opentelemetry/logs/log_record.h b/api/include/opentelemetry/logs/log_record.h index c663c1c9c7..c3ad082107 100644 --- a/api/include/opentelemetry/logs/log_record.h +++ b/api/include/opentelemetry/logs/log_record.h @@ -82,26 +82,27 @@ struct LogRecord core::SystemTimestamp timestamp; // uint64 nanoseconds since Unix epoch trace::TraceId trace_id; // byte sequence trace::SpanId span_id; // byte sequence - trace::TraceFlags trace_flag; // byte - Severity severity; // Severity enum that combines severity_text and severity_number in the - // LogDataModel (can separate in SDK) + trace::TraceFlags trace_flags; // byte + Severity severity; // Severity enum that combines severity_text and severity_number // other fields that will not be set by default nostd::string_view name; // string nostd::string_view body; // currently a simple string, but should be changed "Any" type - common::KeyValueIterable &resource; // key/value pair list - common::KeyValueIterable &attributes; // key/value pair list + nostd::shared_ptr resource; // key/value pair list + nostd::shared_ptr attributes; // key/value pair list /* Default log record if user does not overwrite this. * TODO: find better data type to represent the type for "body" * Future enhancement: Potentially add other constructors to take default arguments * from the user **/ - LogRecord() : resource(_nullKV), attributes(_nullKV) - { - // TODO: in SDK, assign a default timestamp if not specified - name = ""; - } + LogRecord() + : timestamp{core::SystemTimestamp(std::chrono::seconds(0))}, + severity{Severity::kDefault}, + trace_id{trace::TraceId()}, + span_id{trace::SpanId()}, + trace_flags{trace::TraceFlags()} + {} /* for ease of use; user can use this function to convert a map into a KeyValueIterable for the * resources field */ @@ -109,7 +110,8 @@ struct LogRecord nostd::enable_if_t::value> * = nullptr> inline void SetResource(const T &_resource) { - resource = common::KeyValueIterableView(_resource); + resource = + nostd::shared_ptr(new common::KeyValueIterableView{_resource}); } /* for ease of use; user can use this function to convert a map into a KeyValueIterable for the @@ -118,7 +120,8 @@ struct LogRecord nostd::enable_if_t::value> * = nullptr> inline void SetAttributes(const T &_attributes) { - attributes = common::KeyValueIterableView(_attributes); + attributes = nostd::shared_ptr( + new common::KeyValueIterableView{_attributes}); } }; } // namespace logs diff --git a/exporters/ostream/test/ostream_log_test.cc b/exporters/ostream/test/ostream_log_test.cc index bad48e7fe5..979c9bf039 100644 --- a/exporters/ostream/test/ostream_log_test.cc +++ b/exporters/ostream/test/ostream_log_test.cc @@ -238,9 +238,9 @@ TEST(OStreamLogExporter, IntegrationTest) record.timestamp = now; record.severity = logs_api::Severity::kInfo; record.body = "Test Log"; - logger->Log(record); + logger->log(record); - // logger->Log("Test Log"); + // logger->log("Test Log"); // Restore cout's original streambuf std::cout.rdbuf(sbuf);