Aceept also 'warn' string in level::from_str()

This commit is contained in:
gabime 2019-12-13 16:22:20 +02:00
parent 04d0240f8d
commit 3a61dcd360
2 changed files with 3 additions and 1 deletions

View File

@ -34,7 +34,8 @@ SPDLOG_INLINE spdlog::level::level_enum from_str(const std::string &name) SPDLOG
}
level++;
}
return level::off;
// allow warn = warning before giving up
return name == "warn" ? level::warn: level::off;
}
} // namespace level

View File

@ -72,6 +72,7 @@ TEST_CASE("to_level_enum", "[convert_to_level_enum]")
REQUIRE(spdlog::level::from_str("debug") == spdlog::level::debug);
REQUIRE(spdlog::level::from_str("info") == spdlog::level::info);
REQUIRE(spdlog::level::from_str("warning") == spdlog::level::warn);
REQUIRE(spdlog::level::from_str("warn") == spdlog::level::warn);
REQUIRE(spdlog::level::from_str("error") == spdlog::level::err);
REQUIRE(spdlog::level::from_str("critical") == spdlog::level::critical);
REQUIRE(spdlog::level::from_str("off") == spdlog::level::off);