Commit 1822345b authored by Marcin Siodelski's avatar Marcin Siodelski

[3534] Logging information is accessed by getter.

parent 59cd21bb
...@@ -110,9 +110,6 @@ public: ...@@ -110,9 +110,6 @@ public:
static const uint32_t CFGSEL_ALL = 0xFFFFFFFF; static const uint32_t CFGSEL_ALL = 0xFFFFFFFF;
//@} //@}
/// @brief logging specific information
LoggingInfoStorage logging_info_;
/// @brief Default constructor. /// @brief Default constructor.
/// ///
/// This constructor sets configuration sequence number to 0. /// This constructor sets configuration sequence number to 0.
...@@ -160,6 +157,18 @@ public: ...@@ -160,6 +157,18 @@ public:
/// @return true if sequence numbers are equal. /// @return true if sequence numbers are equal.
bool sequenceEquals(const Configuration& other); bool sequenceEquals(const Configuration& other);
/// @brief Returns logging specific configuration.
const LoggingInfoStorage& getLoggingInfo() const {
return (logging_info_);
}
/// @brief Sets logging specific configuration.
///
/// @param logging_info New logging configuration.
void addLoggingInfo(const LoggingInfo& logging_info) {
logging_info_.push_back(logging_info);
}
/// @brief Returns object which represents selection of interfaces. /// @brief Returns object which represents selection of interfaces.
/// ///
/// This function returns a reference to the object which represents the /// This function returns a reference to the object which represents the
...@@ -182,6 +191,9 @@ private: ...@@ -182,6 +191,9 @@ private:
/// @brief Sequence number identifying the configuration. /// @brief Sequence number identifying the configuration.
uint32_t sequence_; uint32_t sequence_;
/// @brief Logging specific information.
LoggingInfoStorage logging_info_;
/// @brief Interface configuration. /// @brief Interface configuration.
/// ///
/// Used to select interfaces on which the DHCP server will listen to /// Used to select interfaces on which the DHCP server will listen to
......
...@@ -113,7 +113,7 @@ void LogConfigParser::parseConfigEntry(isc::data::ConstElementPtr entry) { ...@@ -113,7 +113,7 @@ void LogConfigParser::parseConfigEntry(isc::data::ConstElementPtr entry) {
parseOutputOptions(info.destinations_, output_options); parseOutputOptions(info.destinations_, output_options);
} }
config_->logging_info_.push_back(info); config_->addLoggingInfo(info);
} }
void LogConfigParser::parseOutputOptions(std::vector<LoggingDestination>& destination, void LogConfigParser::parseOutputOptions(std::vector<LoggingDestination>& destination,
...@@ -159,8 +159,9 @@ void LogConfigParser::applyConfiguration() { ...@@ -159,8 +159,9 @@ void LogConfigParser::applyConfiguration() {
std::vector<LoggerSpecification> specs; std::vector<LoggerSpecification> specs;
// Now iterate through all specified loggers // Now iterate through all specified loggers
for (LoggingInfoStorage::const_iterator it = config_->logging_info_.begin(); const LoggingInfoStorage& logging_info = config_->getLoggingInfo();
it != config_->logging_info_.end(); ++it) { for (LoggingInfoStorage::const_iterator it = logging_info.begin();
it != logging_info.end(); ++it) {
// Prepare the objects to define the logging specification // Prepare the objects to define the logging specification
LoggerSpecification spec(it->name_, LoggerSpecification spec(it->name_,
......
...@@ -298,7 +298,7 @@ TEST_F(CfgMgrTest, configuration) { ...@@ -298,7 +298,7 @@ TEST_F(CfgMgrTest, configuration) {
ConfigurationPtr configuration = CfgMgr::instance().getConfiguration(); ConfigurationPtr configuration = CfgMgr::instance().getConfiguration();
ASSERT_TRUE(configuration); ASSERT_TRUE(configuration);
EXPECT_TRUE(configuration->logging_info_.empty()); EXPECT_TRUE(configuration->getLoggingInfo().empty());
} }
// This test verifies that multiple option definitions can be added // This test verifies that multiple option definitions can be added
......
...@@ -159,7 +159,7 @@ ConfigurationTest::enableDDNS(const bool enable) { ...@@ -159,7 +159,7 @@ ConfigurationTest::enableDDNS(const bool enable) {
// Check that by default there are no logging entries // Check that by default there are no logging entries
TEST_F(ConfigurationTest, basic) { TEST_F(ConfigurationTest, basic) {
EXPECT_TRUE(conf_.logging_info_.empty()); EXPECT_TRUE(conf_.getLoggingInfo().empty());
} }
// Check that Configuration can store logging information. // Check that Configuration can store logging information.
...@@ -176,15 +176,15 @@ TEST_F(ConfigurationTest, loggingInfo) { ...@@ -176,15 +176,15 @@ TEST_F(ConfigurationTest, loggingInfo) {
log1.destinations_.push_back(dest); log1.destinations_.push_back(dest);
conf_.logging_info_.push_back(log1); conf_.addLoggingInfo(log1);
EXPECT_EQ("foo", conf_.logging_info_[0].name_); EXPECT_EQ("foo", conf_.getLoggingInfo()[0].name_);
EXPECT_EQ(isc::log::WARN, conf_.logging_info_[0].severity_); EXPECT_EQ(isc::log::WARN, conf_.getLoggingInfo()[0].severity_);
EXPECT_EQ(77, conf_.logging_info_[0].debuglevel_); EXPECT_EQ(77, conf_.getLoggingInfo()[0].debuglevel_);
EXPECT_EQ("some-logfile.txt", conf_.logging_info_[0].destinations_[0].output_); EXPECT_EQ("some-logfile.txt", conf_.getLoggingInfo()[0].destinations_[0].output_);
EXPECT_EQ(5, conf_.logging_info_[0].destinations_[0].maxver_); EXPECT_EQ(5, conf_.getLoggingInfo()[0].destinations_[0].maxver_);
EXPECT_EQ(2097152, conf_.logging_info_[0].destinations_[0].maxsize_); EXPECT_EQ(2097152, conf_.getLoggingInfo()[0].destinations_[0].maxsize_);
} }
// Check that the configuration summary including information about the status // Check that the configuration summary including information about the status
......
...@@ -73,14 +73,14 @@ TEST(DaemonTest, parsingConsoleOutput) { ...@@ -73,14 +73,14 @@ TEST(DaemonTest, parsingConsoleOutput) {
// The parsed configuration should be processed by the daemon and // The parsed configuration should be processed by the daemon and
// stored in configuration storage. // stored in configuration storage.
ASSERT_EQ(1, storage->logging_info_.size()); ASSERT_EQ(1, storage->getLoggingInfo().size());
EXPECT_EQ("kea", storage->logging_info_[0].name_); EXPECT_EQ("kea", storage->getLoggingInfo()[0].name_);
EXPECT_EQ(99, storage->logging_info_[0].debuglevel_); EXPECT_EQ(99, storage->getLoggingInfo()[0].debuglevel_);
EXPECT_EQ(isc::log::DEBUG, storage->logging_info_[0].severity_); EXPECT_EQ(isc::log::DEBUG, storage->getLoggingInfo()[0].severity_);
ASSERT_EQ(1, storage->logging_info_[0].destinations_.size()); ASSERT_EQ(1, storage->getLoggingInfo()[0].destinations_.size());
EXPECT_EQ("stdout" , storage->logging_info_[0].destinations_[0].output_); EXPECT_EQ("stdout" , storage->getLoggingInfo()[0].destinations_[0].output_);
} }
......
...@@ -66,14 +66,14 @@ TEST(LoggingTest, parsingConsoleOutput) { ...@@ -66,14 +66,14 @@ TEST(LoggingTest, parsingConsoleOutput) {
EXPECT_NO_THROW(parser.parseConfiguration(config)); EXPECT_NO_THROW(parser.parseConfiguration(config));
ASSERT_EQ(1, storage->logging_info_.size()); ASSERT_EQ(1, storage->getLoggingInfo().size());
EXPECT_EQ("kea", storage->logging_info_[0].name_); EXPECT_EQ("kea", storage->getLoggingInfo()[0].name_);
EXPECT_EQ(99, storage->logging_info_[0].debuglevel_); EXPECT_EQ(99, storage->getLoggingInfo()[0].debuglevel_);
EXPECT_EQ(isc::log::DEBUG, storage->logging_info_[0].severity_); EXPECT_EQ(isc::log::DEBUG, storage->getLoggingInfo()[0].severity_);
ASSERT_EQ(1, storage->logging_info_[0].destinations_.size()); ASSERT_EQ(1, storage->getLoggingInfo()[0].destinations_.size());
EXPECT_EQ("stdout" , storage->logging_info_[0].destinations_[0].output_); EXPECT_EQ("stdout" , storage->getLoggingInfo()[0].destinations_[0].output_);
} }
// Checks if the LogConfigParser class is able to transform JSON structures // Checks if the LogConfigParser class is able to transform JSON structures
...@@ -106,14 +106,14 @@ TEST(LoggingTest, parsingFile) { ...@@ -106,14 +106,14 @@ TEST(LoggingTest, parsingFile) {
EXPECT_NO_THROW(parser.parseConfiguration(config)); EXPECT_NO_THROW(parser.parseConfiguration(config));
ASSERT_EQ(1, storage->logging_info_.size()); ASSERT_EQ(1, storage->getLoggingInfo().size());
EXPECT_EQ("kea", storage->logging_info_[0].name_); EXPECT_EQ("kea", storage->getLoggingInfo()[0].name_);
EXPECT_EQ(0, storage->logging_info_[0].debuglevel_); EXPECT_EQ(0, storage->getLoggingInfo()[0].debuglevel_);
EXPECT_EQ(isc::log::INFO, storage->logging_info_[0].severity_); EXPECT_EQ(isc::log::INFO, storage->getLoggingInfo()[0].severity_);
ASSERT_EQ(1, storage->logging_info_[0].destinations_.size()); ASSERT_EQ(1, storage->getLoggingInfo()[0].destinations_.size());
EXPECT_EQ("logfile.txt" , storage->logging_info_[0].destinations_[0].output_); EXPECT_EQ("logfile.txt" , storage->getLoggingInfo()[0].destinations_[0].output_);
} }
// Checks if the LogConfigParser class is able to transform data structures // Checks if the LogConfigParser class is able to transform data structures
...@@ -156,19 +156,19 @@ TEST(LoggingTest, multipleLoggers) { ...@@ -156,19 +156,19 @@ TEST(LoggingTest, multipleLoggers) {
EXPECT_NO_THROW(parser.parseConfiguration(config)); EXPECT_NO_THROW(parser.parseConfiguration(config));
ASSERT_EQ(2, storage->logging_info_.size()); ASSERT_EQ(2, storage->getLoggingInfo().size());
EXPECT_EQ("kea", storage->logging_info_[0].name_); EXPECT_EQ("kea", storage->getLoggingInfo()[0].name_);
EXPECT_EQ(0, storage->logging_info_[0].debuglevel_); EXPECT_EQ(0, storage->getLoggingInfo()[0].debuglevel_);
EXPECT_EQ(isc::log::INFO, storage->logging_info_[0].severity_); EXPECT_EQ(isc::log::INFO, storage->getLoggingInfo()[0].severity_);
ASSERT_EQ(1, storage->logging_info_[0].destinations_.size()); ASSERT_EQ(1, storage->getLoggingInfo()[0].destinations_.size());
EXPECT_EQ("logfile.txt" , storage->logging_info_[0].destinations_[0].output_); EXPECT_EQ("logfile.txt" , storage->getLoggingInfo()[0].destinations_[0].output_);
EXPECT_EQ("wombat", storage->logging_info_[1].name_); EXPECT_EQ("wombat", storage->getLoggingInfo()[1].name_);
EXPECT_EQ(99, storage->logging_info_[1].debuglevel_); EXPECT_EQ(99, storage->getLoggingInfo()[1].debuglevel_);
EXPECT_EQ(isc::log::DEBUG, storage->logging_info_[1].severity_); EXPECT_EQ(isc::log::DEBUG, storage->getLoggingInfo()[1].severity_);
ASSERT_EQ(1, storage->logging_info_[1].destinations_.size()); ASSERT_EQ(1, storage->getLoggingInfo()[1].destinations_.size());
EXPECT_EQ("logfile2.txt" , storage->logging_info_[1].destinations_[0].output_); EXPECT_EQ("logfile2.txt" , storage->getLoggingInfo()[1].destinations_[0].output_);
} }
// Checks if the LogConfigParser class is able to transform data structures // Checks if the LogConfigParser class is able to transform data structures
...@@ -204,14 +204,14 @@ TEST(LoggingTest, multipleLoggingDestinations) { ...@@ -204,14 +204,14 @@ TEST(LoggingTest, multipleLoggingDestinations) {
EXPECT_NO_THROW(parser.parseConfiguration(config)); EXPECT_NO_THROW(parser.parseConfiguration(config));
ASSERT_EQ(1, storage->logging_info_.size()); ASSERT_EQ(1, storage->getLoggingInfo().size());
EXPECT_EQ("kea", storage->logging_info_[0].name_); EXPECT_EQ("kea", storage->getLoggingInfo()[0].name_);
EXPECT_EQ(0, storage->logging_info_[0].debuglevel_); EXPECT_EQ(0, storage->getLoggingInfo()[0].debuglevel_);
EXPECT_EQ(isc::log::INFO, storage->logging_info_[0].severity_); EXPECT_EQ(isc::log::INFO, storage->getLoggingInfo()[0].severity_);
ASSERT_EQ(2, storage->logging_info_[0].destinations_.size()); ASSERT_EQ(2, storage->getLoggingInfo()[0].destinations_.size());
EXPECT_EQ("logfile.txt" , storage->logging_info_[0].destinations_[0].output_); EXPECT_EQ("logfile.txt" , storage->getLoggingInfo()[0].destinations_[0].output_);
EXPECT_EQ("stdout" , storage->logging_info_[0].destinations_[1].output_); EXPECT_EQ("stdout" , storage->getLoggingInfo()[0].destinations_[1].output_);
} }
/// @todo There is no easy way to test applyConfiguration() and defaultLogging(). /// @todo There is no easy way to test applyConfiguration() and defaultLogging().
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment