mirror of
https://github.com/vgough/encfs.git
synced 2024-12-01 20:34:04 +01:00
5f0806c5cc
git-vendor-name: easylogging git-vendor-dir: vendor/github.com/muflihun/easyloggingpp git-vendor-repository: https://github.com/muflihun/easyloggingpp git-vendor-ref: master
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_
|