mirror of
https://github.com/vgough/encfs.git
synced 2024-11-25 09:23:13 +01:00
59d74aea1f
git-subtree-dir: vendor/github.com/muflihun/easyloggingpp git-subtree-split: 850ea2a9f151ed648a989dda1cf44e503e45831f
56 lines
2.4 KiB
C++
56 lines
2.4 KiB
C++
#ifndef GLOBAL_CONFIGURATIONS_TEST_H_
|
|
#define GLOBAL_CONFIGURATIONS_TEST_H_
|
|
|
|
#include "test.h"
|
|
|
|
TEST(GlobalConfigurationTest, Parse) {
|
|
const char* globalConfFile = "/tmp/global-conf-test.conf";
|
|
std::fstream confFile(globalConfFile, std::fstream::out);
|
|
confFile
|
|
<< "-- performance\n"
|
|
<< " ## This just skips configuring performance logger any more.\n"
|
|
<< "-- global-test-logger\n"
|
|
<< "* GLOBAL:\n"
|
|
<< " FORMAT = GLOBAL_TEST\n"
|
|
<< "* INFO:\n"
|
|
// Following should be included in format because its inside the quotes
|
|
<< "* DEBUG:\n"
|
|
<< " FORMAT = %datetime %level [%user@%host] [%func] [%loc] %msg ## Comment before EOL char\n"
|
|
<< "## Comment on empty line\n"
|
|
// WARNING is defined by GLOBAL
|
|
<< "* ERROR:\n"
|
|
<< " FORMAT = %datetime %level %msg\n"
|
|
<< "* FATAL:\n"
|
|
<< " FORMAT = %datetime %level %msg\n"
|
|
<< "* VERBOSE:\n"
|
|
<< " FORMAT = %datetime %level-%vlevel %msg\n"
|
|
<< "* TRACE:\n"
|
|
<< " FORMAT = %datetime %level [%func] [%loc] %msg\n";
|
|
confFile.close();
|
|
|
|
Logger* perfLogger = Loggers::getLogger("performance", false);
|
|
CHECK_NOTNULL(perfLogger);
|
|
|
|
std::string perfFormatConf = perfLogger->configurations()->get(Level::Info, ConfigurationType::Format)->value();
|
|
std::string perfFilenameConf = perfLogger->configurations()->get(Level::Info, ConfigurationType::Filename)->value();
|
|
std::size_t totalLoggers = elStorage->registeredLoggers()->size();
|
|
|
|
EXPECT_EQ(Loggers::getLogger("global-test-logger", false), nullptr);
|
|
|
|
Loggers::configureFromGlobal(globalConfFile);
|
|
|
|
EXPECT_EQ(totalLoggers + 1, elStorage->registeredLoggers()->size());
|
|
EXPECT_EQ(perfFormatConf, perfLogger->configurations()->get(Level::Info, ConfigurationType::Format)->value());
|
|
EXPECT_EQ(perfFilenameConf, perfLogger->configurations()->get(Level::Info, ConfigurationType::Filename)->value());
|
|
|
|
// Not nullptr anymore
|
|
Logger* testLogger = Loggers::getLogger("global-test-logger", false);
|
|
EXPECT_NE(testLogger, nullptr);
|
|
|
|
EXPECT_EQ("GLOBAL_TEST", testLogger->configurations()->get(Level::Info, ConfigurationType::Format)->value());
|
|
EXPECT_EQ("%datetime %level [%user@%host] [%func] [%loc] %msg", testLogger->configurations()->get(Level::Debug, ConfigurationType::Format)->value());
|
|
|
|
}
|
|
|
|
#endif // GLOBAL_CONFIGURATIONS_TEST_H_
|