File indexing completed on 2026-05-07 08:53:14
0001
0002
0003
0004 #pragma once
0005
0006 #if defined(SPDLOG_NO_TLS)
0007 #error "This header requires thread local storage support, but SPDLOG_NO_TLS is defined."
0008 #endif
0009
0010 #include <map>
0011 #include <string>
0012
0013 #include <spdlog/common.h>
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 namespace spdlog {
0025 class SPDLOG_API mdc {
0026 public:
0027 using mdc_map_t = std::map<std::string, std::string>;
0028
0029 static void put(const std::string &key, const std::string &value) {
0030 get_context()[key] = value;
0031 }
0032
0033 static std::string get(const std::string &key) {
0034 auto &context = get_context();
0035 auto it = context.find(key);
0036 if (it != context.end()) {
0037 return it->second;
0038 }
0039 return "";
0040 }
0041
0042 static void remove(const std::string &key) { get_context().erase(key); }
0043
0044 static void clear() { get_context().clear(); }
0045
0046 static mdc_map_t &get_context() {
0047 static thread_local mdc_map_t context;
0048 return context;
0049 }
0050 };
0051
0052 }