olp-cpp-sdk
1.22.0
olp-cpp-sdk-core
include
olp
core
logging
LogContext.h
1
/*
2
* Copyright (C) 2019-2024 HERE Europe B.V.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*
16
* SPDX-License-Identifier: Apache-2.0
17
* License-Filename: LICENSE
18
*/
19
20
#pragma once
21
22
#include <olp/core/CoreApi.h>
23
24
#include <functional>
25
#include <memory>
26
#include <string>
27
#include <unordered_map>
28
34
namespace
olp
{
35
namespace
logging {
37
using
LogContext = std::unordered_map<std::string, std::string>;
38
40
using
LogContextSetter = std::function<void(std::shared_ptr<const LogContext>)>;
41
43
using
LogContextGetter = std::function<std::shared_ptr<const LogContext>()>;
44
53
CORE_API
void
SetLogContextGetterSetter(LogContextGetter getter,
54
LogContextSetter setter);
55
57
CORE_API std::shared_ptr<const LogContext> GetContext();
58
60
CORE_API
const
std::string& GetContextValue(
const
std::string& key);
61
71
class
CORE_API
ScopedLogContext
final {
72
public
:
73
ScopedLogContext
(
const
std::shared_ptr<const LogContext>& context);
74
~
ScopedLogContext
();
75
76
private
:
77
std::shared_ptr<const LogContext> context_;
78
std::shared_ptr<const LogContext> prev_context_;
79
};
80
}
// namespace logging
81
}
// namespace olp
olp::logging::ScopedLogContext
The ScopedLogContext class takes ownership of a log context and makes it active on construction and r...
Definition:
LogContext.h:71
olp
Rules all the other namespaces.
Definition:
AppleSignInProperties.h:24
Generated by
1.9.1