Program Listing for File logger_context.h
↰ Return to documentation for file (/tmp/B.puc0r6hi/BUILD/opentelemetry-cpp-1.27.0-build/opentelemetry-cpp-1.27.0/sdk/include/opentelemetry/sdk/logs/logger_context.h)
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include <chrono>
#include <memory>
#include <vector>
#include "logger_config.h"
#include "opentelemetry/sdk/instrumentationscope/scope_configurator.h"
#include "opentelemetry/sdk/logs/processor.h"
#include "opentelemetry/sdk/resource/resource.h"
#include "opentelemetry/version.h"
OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace logs
{
class LoggerContext
{
public:
explicit LoggerContext(
std::vector<std::unique_ptr<LogRecordProcessor>> &&processors,
const opentelemetry::sdk::resource::Resource &resource =
opentelemetry::sdk::resource::Resource::Create({}),
std::unique_ptr<instrumentationscope::ScopeConfigurator<LoggerConfig>> logger_configurator =
std::make_unique<instrumentationscope::ScopeConfigurator<LoggerConfig>>(
instrumentationscope::ScopeConfigurator<LoggerConfig>::Builder(
LoggerConfig::Default())
.Build())) noexcept;
void AddProcessor(std::unique_ptr<LogRecordProcessor> processor) noexcept;
LogRecordProcessor &GetProcessor() const noexcept;
const opentelemetry::sdk::resource::Resource &GetResource() const noexcept;
const instrumentationscope::ScopeConfigurator<LoggerConfig> &GetLoggerConfigurator()
const noexcept;
bool ForceFlush(std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept;
bool Shutdown(std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept;
private:
// order of declaration is important here - resource object should be destroyed after processor.
opentelemetry::sdk::resource::Resource resource_;
std::unique_ptr<LogRecordProcessor> processor_;
std::unique_ptr<instrumentationscope::ScopeConfigurator<LoggerConfig>> logger_configurator_;
};
} // namespace logs
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE