mirror of https://github.com/oxen-io/lokinet
Add test to ensure config loading impacts runtime log level
This commit is contained in:
parent
43998f97c8
commit
9a65f19bb0
|
@ -1,5 +1,7 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include <util/logging/loglevel.hpp>
|
||||
#include <util/logging/logger.hpp>
|
||||
#include <config/config.hpp>
|
||||
|
||||
using TestString = std::string;
|
||||
|
||||
|
@ -61,3 +63,36 @@ TEST_F(LogLevelTest, TestLogLevelToString)
|
|||
EXPECT_EQ("???", LogLevelToString(llarp::eLogNone));
|
||||
}
|
||||
|
||||
TEST_F(LogLevelTest, TestLoggingConfigSideEffects)
|
||||
{
|
||||
// restore original runtime level when we're done
|
||||
llarp::LogContext& logContext = llarp::LogContext::Instance();
|
||||
auto original = logContext.runtimeLevel;
|
||||
|
||||
// LoggingConfig::fromSection updates the runtime level as it reads in conf
|
||||
// values, so feed it values and ensure that the runtime level is updated
|
||||
// appropriately
|
||||
llarp::LoggingConfig config;
|
||||
|
||||
config.fromSection("level", "Trace");
|
||||
EXPECT_EQ(llarp::eLogTrace, logContext.runtimeLevel);
|
||||
|
||||
config.fromSection("level", "Debug");
|
||||
EXPECT_EQ(llarp::eLogDebug, logContext.runtimeLevel);
|
||||
|
||||
config.fromSection("level", "Info");
|
||||
EXPECT_EQ(llarp::eLogInfo, logContext.runtimeLevel);
|
||||
|
||||
config.fromSection("level", "Warn");
|
||||
EXPECT_EQ(llarp::eLogWarn, logContext.runtimeLevel);
|
||||
|
||||
config.fromSection("level", "Error");
|
||||
EXPECT_EQ(llarp::eLogError, logContext.runtimeLevel);
|
||||
|
||||
config.fromSection("level", "None");
|
||||
EXPECT_EQ(llarp::eLogNone, logContext.runtimeLevel);
|
||||
|
||||
|
||||
SetLogLevel(original);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue