6#ifndef SPDLOG_HEADER_ONLY
30 str.begin(), str.end(), str.begin(), [](
char ch) { return static_cast<char>((ch >=
'A' && ch <=
'Z') ? ch + (
'a' -
'A') : ch); });
35 inline std::string&
trim_(std::string& str)
37 const char* spaces =
" \n\r\t";
38 str.erase(str.find_last_not_of(spaces) + 1);
39 str.erase(0, str.find_first_not_of(spaces));
50 inline std::pair<std::string, std::string>
extract_kv_(
char sep,
const std::string& str)
52 auto n = str.find(sep);
54 if (n == std::string::npos)
61 v = str.substr(n + 1);
68 inline std::unordered_map<std::string, std::string>
extract_key_vals_(
const std::string& str)
71 std::istringstream token_stream(str);
72 std::unordered_map<std::string, std::string> rv{};
73 while (std::getline(token_stream, token,
','))
80 rv[kv.first] = kv.second;
93 std::unordered_map<std::string, level::level_enum> levels;
95 bool global_level_found =
false;
97 for (
auto& name_level : key_vals)
99 auto& logger_name = name_level.first;
100 auto level_name =
to_lower_(name_level.second);
103 if (level ==
level::off && level_name !=
"off")
107 if (logger_name.empty())
109 global_level_found =
true;
110 global_level = level;
114 levels[logger_name] = level;
void set_levels(log_levels levels, level::level_enum *global_level)
Definition registry-inl.h:265
static registry & instance()
Definition registry-inl.h:286
#define SPDLOG_INLINE
Definition common.h:47
std::unordered_map< std::string, std::string > extract_key_vals_(const std::string &str)
Definition helpers-inl.h:68
std::pair< std::string, std::string > extract_kv_(char sep, const std::string &str)
Definition helpers-inl.h:50
std::string & to_lower_(std::string &str)
Definition helpers-inl.h:27
std::string & trim_(std::string &str)
Definition helpers-inl.h:35
SPDLOG_INLINE void load_levels(const std::string &input)
Definition helpers-inl.h:85
level_enum
Definition common.h:233
@ info
Definition common.h:236
@ off
Definition common.h:240
SPDLOG_INLINE spdlog::level::level_enum from_str(const std::string &name) SPDLOG_NOEXCEPT
Definition common-inl.h:35
annotation input
Definition tag_strings.h:114