File indexing completed on 2025-04-01 09:06:34
0001
0002
0003
0004 #pragma once
0005
0006 #include <map>
0007 #include <string>
0008
0009 #include <spdlog/common.h>
0010
0011
0012
0013
0014
0015
0016
0017
0018 namespace spdlog {
0019 class SPDLOG_API mdc {
0020 public:
0021 using mdc_map_t = std::map<std::string, std::string>;
0022
0023 static void put(const std::string &key, const std::string &value) {
0024 get_context()[key] = value;
0025 }
0026
0027 static std::string get(const std::string &key) {
0028 auto &context = get_context();
0029 auto it = context.find(key);
0030 if (it != context.end()) {
0031 return it->second;
0032 }
0033 return "";
0034 }
0035
0036 static void remove(const std::string &key) { get_context().erase(key); }
0037
0038 static void clear() { get_context().clear(); }
0039
0040 static mdc_map_t &get_context() {
0041 static thread_local mdc_map_t context;
0042 return context;
0043 }
0044 };
0045
0046 }