mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-28 17:19:34 +08:00
Support custom environment variables for load_env_levels (#3327)
SPDLOG_LEVEL is currently supported to control log levels via load_env_levels. This patch adds support for other environment variable names, such as MYAPP_LEVEL, for load_env_levels.
This commit is contained in:
@@ -19,6 +19,15 @@ TEST_CASE("env", "[cfg]") {
|
||||
#endif
|
||||
load_env_levels();
|
||||
REQUIRE(l1->level() == spdlog::level::warn);
|
||||
|
||||
#ifdef CATCH_PLATFORM_WINDOWS
|
||||
_putenv_s("MYAPP_LEVEL", "l1=trace");
|
||||
#else
|
||||
setenv("MYAPP_LEVEL", "l1=trace", 1);
|
||||
#endif
|
||||
load_env_levels("MYAPP_LEVEL");
|
||||
REQUIRE(l1->level() == spdlog::level::trace);
|
||||
|
||||
spdlog::set_default_logger(spdlog::create<test_sink_st>("cfg-default"));
|
||||
REQUIRE(spdlog::default_logger()->level() == spdlog::level::info);
|
||||
}
|
||||
|
Reference in New Issue
Block a user