33
44#pragma once
55
6- #include < atomic>
6+ #include < stdint.h>
7+ #include < type_traits>
8+ #include < utility>
79
810#include " opentelemetry/version.h"
11+ #include " opentelemetry/context/context.h"
12+ #include " opentelemetry/logs/event_id.h"
913#include " opentelemetry/logs/logger_type_traits.h"
1014#include " opentelemetry/logs/severity.h"
1115#include " opentelemetry/nostd/string_view.h"
@@ -273,6 +277,29 @@ class Logger
273277 // OpenTelemetry C++ user-facing Logs API
274278 //
275279
280+ #if OPENTELEMETRY_ABI_VERSION_NO >= 2
281+ inline bool Enabled (const opentelemetry::context::Context &context,
282+ Severity severity = Severity::kInvalid ) const noexcept
283+ {
284+ if OPENTELEMETRY_LIKELY_CONDITION (!Enabled (severity))
285+ {
286+ return false ;
287+ }
288+ return EnabledImplementation (context, severity);
289+ }
290+
291+ inline bool Enabled (const opentelemetry::context::Context &context,
292+ Severity severity,
293+ const EventId &event_id) const noexcept
294+ {
295+ if OPENTELEMETRY_LIKELY_CONDITION (!Enabled (severity))
296+ {
297+ return false ;
298+ }
299+ return EnabledImplementation (context, severity, event_id);
300+ }
301+ #endif // OPENTELEMETRY_ABI_VERSION_NO >= 2
302+
276303 inline bool Enabled (Severity severity, const EventId &event_id) const noexcept
277304 {
278305 if OPENTELEMETRY_LIKELY_CONDITION (!Enabled (severity))
@@ -466,7 +493,6 @@ class Logger
466493 //
467494
468495protected:
469- // TODO: discuss with community about naming for internal methods.
470496 virtual bool EnabledImplementation (Severity /* severity*/ ,
471497 const EventId & /* event_id*/ ) const noexcept
472498 {
@@ -478,6 +504,21 @@ class Logger
478504 return false ;
479505 }
480506
507+ #if OPENTELEMETRY_ABI_VERSION_NO >= 2
508+ virtual bool EnabledImplementation (const opentelemetry::context::Context & /* context*/ ,
509+ Severity /* severity*/ ) const noexcept
510+ {
511+ return false ;
512+ }
513+
514+ virtual bool EnabledImplementation (const opentelemetry::context::Context & /* context*/ ,
515+ Severity /* severity*/ ,
516+ const EventId & /* event_id*/ ) const noexcept
517+ {
518+ return false ;
519+ }
520+ #endif // OPENTELEMETRY_ABI_VERSION_NO >= 2
521+
481522 void SetMinimumSeverity (uint8_t severity_or_max) noexcept
482523 {
483524 minimum_severity_ = severity_or_max;
0 commit comments