diff --git a/example/example.cpp b/example/example.cpp index b544bec0..bb844c3c 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -28,11 +28,11 @@ int main(int, char *[]) // Optionally load log levels from the SPDLOG_LEVEL env variable or from argv. // For example: set the global level to info and mylogger to to trace: // SPDLOG_LEVEL=info,mylogger=trace && ./example - spdlog::cfg::load_env(); + spdlog::cfg::load_env_levels(); // or from command line: "./example SPDLOG_LEVEL=info,mylogger=trace" // #include "spdlog/cfg/argv.h" // for loading levels from argv - // spdlog::cfg::load_argv(args, argv); + // spdlog::cfg::load_argv_levels(args, argv); spdlog::warn("Easy padding in numbers like {:08d}", 12); spdlog::critical("Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42); diff --git a/include/spdlog/cfg/argv.h b/include/spdlog/cfg/argv.h index 71ddb9ea..a842e107 100644 --- a/include/spdlog/cfg/argv.h +++ b/include/spdlog/cfg/argv.h @@ -21,7 +21,7 @@ namespace spdlog { namespace cfg { // search for SPDLOG_LEVEL= in the args and use it to init the levels -void load_argv(int args, char **argv) +void load_argv_levels(int args, char **argv) { const std::string spdlog_level_prefix = "SPDLOG_LEVEL="; for (int i = 1; i < args; i++) diff --git a/include/spdlog/cfg/env.h b/include/spdlog/cfg/env.h index 4b4a22c7..115b676f 100644 --- a/include/spdlog/cfg/env.h +++ b/include/spdlog/cfg/env.h @@ -25,7 +25,7 @@ namespace spdlog { namespace cfg { -void load_env() +void load_env_levels() { auto env_val = details::os::getenv("SPDLOG_LEVEL"); auto levels = helpers::extract_levels(env_val); diff --git a/tests/test_cfg.cpp b/tests/test_cfg.cpp index 8caf13ea..7e6f36e5 100644 --- a/tests/test_cfg.cpp +++ b/tests/test_cfg.cpp @@ -4,8 +4,8 @@ #include #include -using spdlog::cfg::load_argv; -using spdlog::cfg::load_env; +using spdlog::cfg::load_argv_levels; +using spdlog::cfg::load_env_levels; using spdlog::sinks::test_sink_st; TEST_CASE("env", "[cfg]") @@ -17,7 +17,7 @@ TEST_CASE("env", "[cfg]") #else setenv("SPDLOG_LEVEL", "l1=warn", 1); #endif - load_env(); + load_env_levels(); REQUIRE(l1->level() == spdlog::level::warn); spdlog::set_default_logger(spdlog::create("cfg-default")); REQUIRE(spdlog::default_logger()->level() == spdlog::level::info); @@ -27,7 +27,7 @@ TEST_CASE("argv1", "[cfg]") { spdlog::drop("l1"); const char *argv[] = {"ignore", "SPDLOG_LEVEL=l1=warn"}; - load_argv(2, const_cast(argv)); + load_argv_levels(2, const_cast(argv)); auto l1 = spdlog::create("l1"); REQUIRE(l1->level() == spdlog::level::warn); REQUIRE(spdlog::default_logger()->level() == spdlog::level::info); @@ -37,7 +37,7 @@ TEST_CASE("argv2", "[cfg]") { spdlog::drop("l1"); const char *argv[] = {"ignore", "SPDLOG_LEVEL=l1=warn,trace"}; - load_argv(2, const_cast(argv)); + load_argv_levels(2, const_cast(argv)); auto l1 = spdlog::create("l1"); REQUIRE(l1->level() == spdlog::level::warn); REQUIRE(spdlog::default_logger()->level() == spdlog::level::trace); @@ -48,7 +48,7 @@ TEST_CASE("argv3", "[cfg]") { spdlog::drop("l1"); const char *argv[] = {"ignore", "SPDLOG_LEVEL="}; - load_argv(2, const_cast(argv)); + load_argv_levels(2, const_cast(argv)); auto l1 = spdlog::create("l1"); REQUIRE(l1->level() == spdlog::level::info); REQUIRE(spdlog::default_logger()->level() == spdlog::level::info); @@ -58,7 +58,7 @@ TEST_CASE("argv4", "[cfg]") { spdlog::drop("l1"); const char *argv[] = {"ignore", "SPDLOG_LEVEL=junk"}; - load_argv(2, const_cast(argv)); + load_argv_levels(2, const_cast(argv)); auto l1 = spdlog::create("l1"); REQUIRE(l1->level() == spdlog::level::info); } @@ -67,7 +67,7 @@ TEST_CASE("argv5", "[cfg]") { spdlog::drop("l1"); const char *argv[] = {"ignore", "ignore", "SPDLOG_LEVEL=l1=warn,trace"}; - load_argv(3, const_cast(argv)); + load_argv_levels(3, const_cast(argv)); auto l1 = spdlog::create("l1"); REQUIRE(l1->level() == spdlog::level::warn); REQUIRE(spdlog::default_logger()->level() == spdlog::level::trace); @@ -78,7 +78,7 @@ TEST_CASE("argv6", "[cfg]") { spdlog::set_level(spdlog::level::err); const char *argv[] = {""}; - load_argv(1, const_cast(argv)); + load_argv_levels(1, const_cast(argv)); REQUIRE(spdlog::default_logger()->level() == spdlog::level::err); spdlog::set_level(spdlog::level::info); } @@ -87,7 +87,7 @@ TEST_CASE("argv7", "[cfg]") { spdlog::set_level(spdlog::level::err); const char *argv[] = {""}; - load_argv(0, const_cast(argv)); + load_argv_levels(0, const_cast(argv)); REQUIRE(spdlog::default_logger()->level() == spdlog::level::err); spdlog::set_level(spdlog::level::info); }