This commit is contained in:
gabime 2019-12-11 00:42:00 +02:00
parent 4119b72d50
commit b278baf94e

View File

@ -58,8 +58,8 @@ inline name_val_pair extract_kv_(char sep, const std::string &str)
return std::make_pair(trim_(k), trim_(v)); return std::make_pair(trim_(k), trim_(v));
} }
// return vector of key/value pairs from str. // return vector of key/value pairs from sequence of "K1=V1,K2=V2,.."
// str format: "a=A,b=B,c=C,d=D,.." // "a=AAA,b=BBB,c=CCC,.." => {("a","AAA"),("b","BBB"),("c", "CCC"),...}
SPDLOG_INLINE std::unordered_map<std::string, std::string> extract_key_vals_(const std::string &str) SPDLOG_INLINE std::unordered_map<std::string, std::string> extract_key_vals_(const std::string &str)
{ {
std::string token; std::string token;
@ -67,9 +67,13 @@ SPDLOG_INLINE std::unordered_map<std::string, std::string> extract_key_vals_(con
std::unordered_map<std::string, std::string> rv; std::unordered_map<std::string, std::string> rv;
while (std::getline(token_stream, token, ',')) while (std::getline(token_stream, token, ','))
{ {
if(token.empty())
{
continue;
}
auto kv = extract_kv_('=', token); auto kv = extract_kv_('=', token);
// empty logger name or '*' marks all loggers // '*' marks all loggers
if (kv.first.empty()) if (kv.first.empty())
{ {
kv.first = "*"; kv.first = "*";