Class LoggerContext
Defined in File logger_context.h
Class Documentation
-
class LoggerContext
A class which stores the LoggerContext context.
This class meets the following design criteria:
A shared reference between LoggerProvider and Logger instantiated.
A thread-safe class that allows updating/altering processor/exporter pipelines and sampling config.
The owner/destroyer of Processors/Exporters. These will remain active until this class is destroyed. I.e. Sampling, Exporting, flushing, Custom Iterator etc. are all ok if this object is alive, and they will work together. If this object is destroyed, then no shared references to Processor, Exporter, Recordable, Custom Iterator etc. should exist, and all associated pipelines will have been flushed.
Public Functions
-
explicit LoggerContext(std::vector<std::unique_ptr<LogRecordProcessor>> &&processors, const opentelemetry::sdk::resource::Resource &resource = opentelemetry::sdk::resource::Resource::Create({})) noexcept
-
void AddProcessor(std::unique_ptr<LogRecordProcessor> processor) noexcept
Attaches a log processor to list of configured processors to this logger context. Processor once attached can’t be removed.
Note: This method is not thread safe.
- Parameters:
processor – The new log processor for this tracer. This must not be a nullptr. Ownership is given to the
LoggerContext
.
-
LogRecordProcessor &GetProcessor() const noexcept
Obtain the configured (composite) processor.
Note: When more than one processor is active, this will return an “aggregate” processor
-
const opentelemetry::sdk::resource::Resource &GetResource() const noexcept
Obtain the resource associated with this tracer context.
- Returns:
The resource for this tracer context.
-
bool ForceFlush(std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept
Force all active LogProcessors to flush any buffered logs within the given timeout.
-
bool Shutdown(std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept
Shutdown the log processor associated with this tracer provider.