olp-cpp-sdk 1.24.0
Loading...
Searching...
No Matches
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
34namespace olp {
35namespace logging {
37using LogContext = std::unordered_map<std::string, std::string>;
38
40using LogContextSetter = std::function<void(std::shared_ptr<const LogContext>)>;
41
43using LogContextGetter = std::function<std::shared_ptr<const LogContext>()>;
44
53CORE_API void SetLogContextGetterSetter(LogContextGetter getter,
54 LogContextSetter setter);
55
57CORE_API std::shared_ptr<const LogContext> GetContext();
58
60CORE_API const std::string& GetContextValue(const std::string& key);
61
71class CORE_API ScopedLogContext final {
72 public:
73 ScopedLogContext(const std::shared_ptr<const LogContext>& context);
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
The ScopedLogContext class takes ownership of a log context and makes it active on construction and r...
Definition LogContext.h:71
Rules all the other namespaces.
Definition AppleSignInProperties.h:24