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

Adding new Logger:log() method #1005

Merged
merged 4 commits into from
Sep 30, 2021
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
21 changes: 19 additions & 2 deletions api/include/opentelemetry/logs/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class Logger
*/
template <class T,
nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value> * = nullptr>
inline void Log(Severity severity, const T &attributes) noexcept
void Log(Severity severity, const T &attributes) noexcept
{
this->Log(severity, "", "", std::map<std::string, std::string>{}, attributes, {}, {}, {},
std::chrono::system_clock::now());
Expand All @@ -157,7 +157,7 @@ class Logger
*/
template <class T,
nostd::enable_if_t<common::detail::is_key_value_iterable<T>::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<std::string, std::string>{}, attributes, {}, {}, {},
std::chrono::system_clock::now());
Expand Down Expand Up @@ -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,
lalitb marked this conversation as resolved.
Show resolved Hide resolved
nostd::string_view name,
common::KeyValueIterable &attributes) noexcept
{
this->Log(severity, name, {},
common::KeyValueIterableView<
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>>({}),
attributes, {}, {}, {}, std::chrono::system_clock::now());
}

/** Trace severity overloads **/

/**
Expand Down
4 changes: 2 additions & 2 deletions sdk/include/opentelemetry/sdk/logs/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down