summaryrefslogtreecommitdiffstats
path: root/src/jaegertracing/opentelemetry-cpp/sdk/src/logs/logger_context.cc
blob: b0025ff724f442c19ffef403b39887f1f87bc302 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#ifdef ENABLE_LOGS_PREVIEW

#  include "opentelemetry/sdk/logs/logger_context.h"
#  include "opentelemetry/sdk/logs/multi_log_processor.h"

#  include <memory>
#  include <vector>

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace logs
{

LoggerContext::LoggerContext(std::vector<std::unique_ptr<LogProcessor>> &&processors,
                             opentelemetry::sdk::resource::Resource resource) noexcept
    : resource_(resource),
      processor_(std::unique_ptr<LogProcessor>(new MultiLogProcessor(std::move(processors))))
{}

void LoggerContext::AddProcessor(std::unique_ptr<LogProcessor> processor) noexcept
{
  auto multi_processor = static_cast<MultiLogProcessor *>(processor_.get());
  multi_processor->AddProcessor(std::move(processor));
}

LogProcessor &LoggerContext::GetProcessor() const noexcept
{
  return *processor_;
}

const opentelemetry::sdk::resource::Resource &LoggerContext::GetResource() const noexcept
{
  return resource_;
}

bool LoggerContext::ForceFlush(std::chrono::microseconds timeout) noexcept
{
  return processor_->ForceFlush(timeout);
}

bool LoggerContext::Shutdown(std::chrono::microseconds timeout) noexcept
{
  return processor_->ForceFlush(timeout);
}

}  // namespace logs
}  // namespace sdk

OPENTELEMETRY_END_NAMESPACE
#endif