]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3534] Logging information is accessed by getter.
authorMarcin Siodelski <marcin@isc.org>
Fri, 29 Aug 2014 07:54:47 +0000 (09:54 +0200)
committerMarcin Siodelski <marcin@isc.org>
Fri, 29 Aug 2014 07:54:47 +0000 (09:54 +0200)
src/lib/dhcpsrv/configuration.h
src/lib/dhcpsrv/logging.cc
src/lib/dhcpsrv/tests/cfgmgr_unittest.cc
src/lib/dhcpsrv/tests/configuration_unittest.cc
src/lib/dhcpsrv/tests/daemon_unittest.cc
src/lib/dhcpsrv/tests/logging_unittest.cc

index 4bc48cf954a472bb2a11215b430e74e0c5ce8ef9..40614679cad0d18042b9b353a67848282a79ce17 100644 (file)
@@ -110,9 +110,6 @@ public:
     static const uint32_t CFGSEL_ALL     = 0xFFFFFFFF;
     //@}
 
-    /// @brief logging specific information
-    LoggingInfoStorage logging_info_;
-
     /// @brief Default constructor.
     ///
     /// This constructor sets configuration sequence number to 0.
@@ -160,6 +157,18 @@ public:
     /// @return true if sequence numbers are equal.
     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.
     ///
     /// This function returns a reference to the object which represents the
@@ -182,6 +191,9 @@ private:
     /// @brief Sequence number identifying the configuration.
     uint32_t sequence_;
 
+    /// @brief Logging specific information.
+    LoggingInfoStorage logging_info_;
+
     /// @brief Interface configuration.
     ///
     /// Used to select interfaces on which the DHCP server will listen to
index 27ec41dfc35d834c7ba02d5c83284608e2dd1322..98e28a4c709e90f47e69e67333db2bd089b0831d 100644 (file)
@@ -113,7 +113,7 @@ void LogConfigParser::parseConfigEntry(isc::data::ConstElementPtr entry) {
         parseOutputOptions(info.destinations_, output_options);
     }
     
-    config_->logging_info_.push_back(info);
+    config_->addLoggingInfo(info);
 }
 
 void LogConfigParser::parseOutputOptions(std::vector<LoggingDestination>& destination,
@@ -159,8 +159,9 @@ void LogConfigParser::applyConfiguration() {
     std::vector<LoggerSpecification> specs;
 
     // Now iterate through all specified loggers
-    for (LoggingInfoStorage::const_iterator it = config_->logging_info_.begin();
-         it != config_->logging_info_.end(); ++it) {
+    const LoggingInfoStorage& logging_info = config_->getLoggingInfo();
+    for (LoggingInfoStorage::const_iterator it = logging_info.begin();
+         it != logging_info.end(); ++it) {
 
         // Prepare the objects to define the logging specification
         LoggerSpecification spec(it->name_,
index 0316a562fa2601019febbd7cd46216b81c03555a..4bc6be0b1709ed3d3110256b658ee74719ce6c06 100644 (file)
@@ -298,7 +298,7 @@ TEST_F(CfgMgrTest, configuration) {
     ConfigurationPtr configuration = CfgMgr::instance().getConfiguration();
     ASSERT_TRUE(configuration);
 
-    EXPECT_TRUE(configuration->logging_info_.empty());
+    EXPECT_TRUE(configuration->getLoggingInfo().empty());
 }
 
 // This test verifies that multiple option definitions can be added
index 833663c8ab646aa5b5d6bef18be46755b0f8b2c6..40b35c5749f8abd4b04fdd25008385fe38852707 100644 (file)
@@ -159,7 +159,7 @@ ConfigurationTest::enableDDNS(const bool enable) {
 
 // Check that by default there are no logging entries
 TEST_F(ConfigurationTest, basic) {
-    EXPECT_TRUE(conf_.logging_info_.empty());
+    EXPECT_TRUE(conf_.getLoggingInfo().empty());
 }
 
 // Check that Configuration can store logging information.
@@ -176,15 +176,15 @@ TEST_F(ConfigurationTest, loggingInfo) {
 
     log1.destinations_.push_back(dest);
 
-    conf_.logging_info_.push_back(log1);
+    conf_.addLoggingInfo(log1);
 
-    EXPECT_EQ("foo", conf_.logging_info_[0].name_);
-    EXPECT_EQ(isc::log::WARN, conf_.logging_info_[0].severity_);
-    EXPECT_EQ(77, conf_.logging_info_[0].debuglevel_);
+    EXPECT_EQ("foo", conf_.getLoggingInfo()[0].name_);
+    EXPECT_EQ(isc::log::WARN, conf_.getLoggingInfo()[0].severity_);
+    EXPECT_EQ(77, conf_.getLoggingInfo()[0].debuglevel_);
 
-    EXPECT_EQ("some-logfile.txt", conf_.logging_info_[0].destinations_[0].output_);
-    EXPECT_EQ(5, conf_.logging_info_[0].destinations_[0].maxver_);
-    EXPECT_EQ(2097152, conf_.logging_info_[0].destinations_[0].maxsize_);
+    EXPECT_EQ("some-logfile.txt", conf_.getLoggingInfo()[0].destinations_[0].output_);
+    EXPECT_EQ(5, conf_.getLoggingInfo()[0].destinations_[0].maxver_);
+    EXPECT_EQ(2097152, conf_.getLoggingInfo()[0].destinations_[0].maxsize_);
 }
 
 // Check that the configuration summary including information about the status
index 572812d3f16767878371fe7f5cd49b6f6083d1d4..5d0e0fbd12d885021689859079b34a2e0afd5ace 100644 (file)
@@ -73,14 +73,14 @@ TEST(DaemonTest, parsingConsoleOutput) {
 
     // The parsed configuration should be processed by the daemon and
     // 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(99, storage->logging_info_[0].debuglevel_);
-    EXPECT_EQ(isc::log::DEBUG, storage->logging_info_[0].severity_);
+    EXPECT_EQ("kea", storage->getLoggingInfo()[0].name_);
+    EXPECT_EQ(99, storage->getLoggingInfo()[0].debuglevel_);
+    EXPECT_EQ(isc::log::DEBUG, storage->getLoggingInfo()[0].severity_);
 
-    ASSERT_EQ(1, storage->logging_info_[0].destinations_.size());
-    EXPECT_EQ("stdout" , storage->logging_info_[0].destinations_[0].output_);
+    ASSERT_EQ(1, storage->getLoggingInfo()[0].destinations_.size());
+    EXPECT_EQ("stdout" , storage->getLoggingInfo()[0].destinations_[0].output_);
 }
 
 
index 41fc8603ba68b9e73cf817c8f24dfde50cd47887..b2d54fa022e7231938d99df8cb9190e367bf13a8 100644 (file)
@@ -66,14 +66,14 @@ TEST(LoggingTest, parsingConsoleOutput) {
 
     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(99, storage->logging_info_[0].debuglevel_);
-    EXPECT_EQ(isc::log::DEBUG, storage->logging_info_[0].severity_);
+    EXPECT_EQ("kea", storage->getLoggingInfo()[0].name_);
+    EXPECT_EQ(99, storage->getLoggingInfo()[0].debuglevel_);
+    EXPECT_EQ(isc::log::DEBUG, storage->getLoggingInfo()[0].severity_);
 
-    ASSERT_EQ(1, storage->logging_info_[0].destinations_.size());
-    EXPECT_EQ("stdout" , storage->logging_info_[0].destinations_[0].output_);
+    ASSERT_EQ(1, storage->getLoggingInfo()[0].destinations_.size());
+    EXPECT_EQ("stdout" , storage->getLoggingInfo()[0].destinations_[0].output_);
 }
 
 // Checks if the LogConfigParser class is able to transform JSON structures
@@ -106,14 +106,14 @@ TEST(LoggingTest, parsingFile) {
 
     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(0, storage->logging_info_[0].debuglevel_);
-    EXPECT_EQ(isc::log::INFO, storage->logging_info_[0].severity_);
+    EXPECT_EQ("kea", storage->getLoggingInfo()[0].name_);
+    EXPECT_EQ(0, storage->getLoggingInfo()[0].debuglevel_);
+    EXPECT_EQ(isc::log::INFO, storage->getLoggingInfo()[0].severity_);
 
-    ASSERT_EQ(1, storage->logging_info_[0].destinations_.size());
-    EXPECT_EQ("logfile.txt" , storage->logging_info_[0].destinations_[0].output_);
+    ASSERT_EQ(1, storage->getLoggingInfo()[0].destinations_.size());
+    EXPECT_EQ("logfile.txt" , storage->getLoggingInfo()[0].destinations_[0].output_);
 }
 
 // Checks if the LogConfigParser class is able to transform data structures
@@ -156,19 +156,19 @@ TEST(LoggingTest, multipleLoggers) {
 
     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(0, storage->logging_info_[0].debuglevel_);
-    EXPECT_EQ(isc::log::INFO, storage->logging_info_[0].severity_);
-    ASSERT_EQ(1, storage->logging_info_[0].destinations_.size());
-    EXPECT_EQ("logfile.txt" , storage->logging_info_[0].destinations_[0].output_);
+    EXPECT_EQ("kea", storage->getLoggingInfo()[0].name_);
+    EXPECT_EQ(0, storage->getLoggingInfo()[0].debuglevel_);
+    EXPECT_EQ(isc::log::INFO, storage->getLoggingInfo()[0].severity_);
+    ASSERT_EQ(1, storage->getLoggingInfo()[0].destinations_.size());
+    EXPECT_EQ("logfile.txt" , storage->getLoggingInfo()[0].destinations_[0].output_);
 
-    EXPECT_EQ("wombat", storage->logging_info_[1].name_);
-    EXPECT_EQ(99, storage->logging_info_[1].debuglevel_);
-    EXPECT_EQ(isc::log::DEBUG, storage->logging_info_[1].severity_);
-    ASSERT_EQ(1, storage->logging_info_[1].destinations_.size());
-    EXPECT_EQ("logfile2.txt" , storage->logging_info_[1].destinations_[0].output_);
+    EXPECT_EQ("wombat", storage->getLoggingInfo()[1].name_);
+    EXPECT_EQ(99, storage->getLoggingInfo()[1].debuglevel_);
+    EXPECT_EQ(isc::log::DEBUG, storage->getLoggingInfo()[1].severity_);
+    ASSERT_EQ(1, storage->getLoggingInfo()[1].destinations_.size());
+    EXPECT_EQ("logfile2.txt" , storage->getLoggingInfo()[1].destinations_[0].output_);
 }
 
 // Checks if the LogConfigParser class is able to transform data structures
@@ -204,14 +204,14 @@ TEST(LoggingTest, multipleLoggingDestinations) {
 
     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(0, storage->logging_info_[0].debuglevel_);
-    EXPECT_EQ(isc::log::INFO, storage->logging_info_[0].severity_);
-    ASSERT_EQ(2, storage->logging_info_[0].destinations_.size());
-    EXPECT_EQ("logfile.txt" , storage->logging_info_[0].destinations_[0].output_);
-    EXPECT_EQ("stdout" , storage->logging_info_[0].destinations_[1].output_);
+    EXPECT_EQ("kea", storage->getLoggingInfo()[0].name_);
+    EXPECT_EQ(0, storage->getLoggingInfo()[0].debuglevel_);
+    EXPECT_EQ(isc::log::INFO, storage->getLoggingInfo()[0].severity_);
+    ASSERT_EQ(2, storage->getLoggingInfo()[0].destinations_.size());
+    EXPECT_EQ("logfile.txt" , storage->getLoggingInfo()[0].destinations_[0].output_);
+    EXPECT_EQ("stdout" , storage->getLoggingInfo()[0].destinations_[1].output_);
 }
 
 /// @todo There is no easy way to test applyConfiguration() and defaultLogging().