AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
mdc.hpp
1/*
2 ANCH Framework: ANother C++ Hack is a C++ framework based on C++23 standard
3 Copyright (C) 2012 Vincent Lachenal
4
5 This file is part of ANCH Framework.
6
7 ANCH Framework is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 ANCH Framework is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with ANCH Framework. If not, see <https://www.gnu.org/licenses/>.
19*/
20#pragma once
21
22#include "anch-log-export.hpp"
23
24#include <string>
25#include <map>
26
27namespace anch::log {
28
30 extern ANCH_LOG_EXPORT const std::string MDC_THREAD_ID;
31
33 extern ANCH_LOG_EXPORT std::map<std::string,std::string> MDC_CONST;
34
44 class ANCH_LOG_EXPORT MapDiagnosticContext {
45
46 // Attributes +
47 private:
49 std::map<std::string,std::string> _context;
50 // Attributes -
51
52 // Constructors +
53 public:
58
63
68 // Constructors -
69
70 // Destructors +
71 public:
76 // Destructors -
77
78 // Methods +
79 public:
86 void add(const std::string& key, const std::string& value) noexcept;
87
94 void put(const std::string& key, const std::string& value) noexcept;
95
101 void remove(const std::string& key) noexcept;
102
108 const std::map<std::string,std::string>& get() const noexcept;
109
113 void reset() noexcept;
114
120 void copy(const MapDiagnosticContext& other) noexcept;
121 // Methods -
122
123 };
124
126 extern ANCH_LOG_EXPORT thread_local MapDiagnosticContext MDC;
127
128}
129
130#include "log/impl/mdc.hpp"
void put(const std::string &key, const std::string &value) noexcept
void remove(const std::string &key) noexcept
void add(const std::string &key, const std::string &value) noexcept
const std::map< std::string, std::string > & get() const noexcept
MapDiagnosticContext(const MapDiagnosticContext &)=delete
MapDiagnosticContext(MapDiagnosticContext &&)=delete
void copy(const MapDiagnosticContext &other) noexcept
AnCH logging library namespace.
Definition constants.hpp:26
const std::string MDC_THREAD_ID
std::map< std::string, std::string > MDC_CONST
MapDiagnosticContext MDC