From 4c61f7b0f3455e449c49fd6e347b1b8e38498a21 Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Thu, 30 Sep 2021 00:17:26 -0700 Subject: [PATCH] Adding new Logger:log() method (#1005) --- api/include/opentelemetry/logs/logger.h | 21 +++++++++++++++++++-- sdk/include/opentelemetry/sdk/logs/logger.h | 4 ++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/api/include/opentelemetry/logs/logger.h b/api/include/opentelemetry/logs/logger.h index 38b79e8bdf..5ce878d760 100644 --- a/api/include/opentelemetry/logs/logger.h +++ b/api/include/opentelemetry/logs/logger.h @@ -143,7 +143,7 @@ class Logger */ template ::value> * = nullptr> - inline void Log(Severity severity, const T &attributes) noexcept + void Log(Severity severity, const T &attributes) noexcept { this->Log(severity, "", "", std::map{}, attributes, {}, {}, {}, std::chrono::system_clock::now()); @@ -157,7 +157,7 @@ class Logger */ template ::value> * = nullptr> - inline void Log(Severity severity, nostd::string_view name, const T &attributes) noexcept + void Log(Severity severity, nostd::string_view name, const T &attributes) noexcept { this->Log(severity, name, "", std::map{}, attributes, {}, {}, {}, std::chrono::system_clock::now()); @@ -189,6 +189,23 @@ class Logger this->Log(severity, name, "", {}, attributes, {}, {}, {}, std::chrono::system_clock::now()); } + /** + * Writes a log. + * @param severity The severity of the log + * @param name The name of the log + * @param attributes The attributes, stored as a 2D list of key/value pairs, that are associated + * with the log event + */ + void Log(Severity severity, + nostd::string_view name, + common::KeyValueIterable &attributes) noexcept + { + this->Log(severity, name, {}, + common::KeyValueIterableView< + std::initializer_list>>({}), + attributes, {}, {}, {}, std::chrono::system_clock::now()); + } + /** Trace severity overloads **/ /** diff --git a/sdk/include/opentelemetry/sdk/logs/logger.h b/sdk/include/opentelemetry/sdk/logs/logger.h index a1d758be4c..ca15372a11 100644 --- a/sdk/include/opentelemetry/sdk/logs/logger.h +++ b/sdk/include/opentelemetry/sdk/logs/logger.h @@ -52,8 +52,8 @@ class Logger final : public opentelemetry::logs::Logger nostd::string_view body, const opentelemetry::common::KeyValueIterable &resource, const opentelemetry::common::KeyValueIterable &attributes, - trace::TraceId trace_id, - trace::SpanId span_id, + opentelemetry::trace::TraceId trace_id, + opentelemetry::trace::SpanId span_id, trace::TraceFlags trace_flags, opentelemetry::common::SystemTimestamp timestamp) noexcept override;