This commit is contained in:
gabime 2019-12-21 19:59:23 +02:00
parent a87700a28c
commit 1a1c37db7c
3 changed files with 6 additions and 10 deletions

View File

@ -23,10 +23,10 @@ void syslog_example();
#include <spdlog/loaders/env.h>
#include <spdlog/loaders/argv.h>
int main(int args, const char *argv[])
int main(int args, char *argv[])
{
spdlog::loaders::load_env();
//spdlog::loaders::load_env();
spdlog::loaders::load_argv(args, argv);
spdlog::info("HELLO INFO");

View File

@ -36,9 +36,5 @@ void load_argv(int args, char **argv)
}
}
void load_argv(int args, const char **argv)
{
return load_argv(args, const_cast<const char**>(argv));
}
} // namespace loaders
} // namespace spdlog

View File

@ -20,7 +20,7 @@ TEST_CASE("env", "[loaders]")
TEST_CASE("argv1", "[loaders]")
{
const char *argv[] = {"ignore", "SPDLOG_LEVEL=l1=warn"};
load_argv(2, argv);
load_argv(2, const_cast<char**>(argv));
auto l1 = spdlog::create<spdlog::sinks::test_sink_st>("l1");
REQUIRE(l1->level() == spdlog::level::warn);
REQUIRE(spdlog::default_logger()->level() == spdlog::level::info);
@ -30,7 +30,7 @@ TEST_CASE("argv1", "[loaders]")
TEST_CASE("argv2", "[loaders]")
{
const char *argv[] = {"ignore", "SPDLOG_LEVEL=l1=warn,trace"};
load_argv(2, argv);
load_argv(2, const_cast<char**>(argv));
auto l1 = spdlog::create<spdlog::sinks::test_sink_st>("l1");
REQUIRE(l1->level() == spdlog::level::warn);
REQUIRE(spdlog::default_logger()->level() == spdlog::level::trace);
@ -40,7 +40,7 @@ TEST_CASE("argv2", "[loaders]")
TEST_CASE("argv3", "[loaders]")
{
const char *argv[] = {"ignore", "SPDLOG_LEVEL="};
load_argv(2, argv);
load_argv(2, const_cast<char**>(argv));
auto l1 = spdlog::create<spdlog::sinks::test_sink_st>("l1");
REQUIRE(l1->level() == spdlog::level::info);
REQUIRE(spdlog::default_logger()->level() == spdlog::level::info);
@ -50,7 +50,7 @@ TEST_CASE("argv3", "[loaders]")
TEST_CASE("argv4", "[loaders]")
{
const char *argv[] = {"ignore", "SPDLOG_LEVEL=junk"};
load_argv(2, argv);
load_argv(2, const_cast<char**>(argv));
auto l1 = spdlog::create<spdlog::sinks::test_sink_st>("l1");
REQUIRE(l1->level() == spdlog::level::info);
spdlog::drop(l1->name());