Fix #3525: Make level name matching case-insensitive (#3535)

Modified from_str() to perform case-insensitive comparison for all level names.
This allows environment variables and SPDLOG_LEVEL_NAMES to use uppercase or
mixed case level names (e.g., DEBUG, INFO, Warning) while maintaining full
backward compatibility with existing lowercase names.
This commit is contained in:
SamareshSingh
2026-02-09 13:58:20 -06:00
committed by GitHub
parent 6c5d63291a
commit 566b2d1404
3 changed files with 60 additions and 3 deletions

View File

@@ -73,6 +73,17 @@ TEST_CASE("to_level_enum", "[convert_to_level_enum]") {
REQUIRE(spdlog::level::from_str("critical") == spdlog::level::critical);
REQUIRE(spdlog::level::from_str("off") == spdlog::level::off);
REQUIRE(spdlog::level::from_str("null") == spdlog::level::off);
REQUIRE(spdlog::level::from_str("TRACE") == spdlog::level::trace);
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("ERR") == spdlog::level::err);
REQUIRE(spdlog::level::from_str("CRITICAL") == spdlog::level::critical);
REQUIRE(spdlog::level::from_str("OFF") == spdlog::level::off);
REQUIRE(spdlog::level::from_str("TrAcE") == spdlog::level::trace);
REQUIRE(spdlog::level::from_str("DeBuG") == spdlog::level::debug);
}
TEST_CASE("periodic flush", "[periodic_flush]") {