Parcourir la source

[trac738] Add messages for the statistics module.

Stephen Morris il y a 14 ans
Parent
commit
2b97fc4f4f

+ 21 - 7
src/bin/auth/auth_messages.mes

@@ -26,6 +26,12 @@ communication over the previously-created channel to the configuration manager.
 A debug message, issued when the authoritative server has posted a request to
 be notified when new configuration information is available.
 
+% AUTH_CONFIG_LOAD_FAIL load of configuration failed: %1
+At attempt to configure the server with information from the configuration
+database has failed, the reason being given in the message. The server will
+continue its initialization although it may not be configured in the desired
+way.
+
 % AUTH_DNSSERVICES_CREATED  DNS services created
 A debug message indicating that the component that will handling incoming
 queries for the authoritiative server (DNSServices) has been successfully
@@ -35,11 +41,9 @@ created.
 A debug message indicating that the authoritiative server has successfully
 accessed the keyring holding TSIG keys.
 
-% AUTH_SERVER_CONFIG_FAIL load of configuration failed: %1
-At attempt to configure the server with information from the configuration
-database has failed, the reason being given in the message. The server will
-continue its initialization although it may not be configured in the desired
-way.
+% AUTH_NO_STATS_SESSION session interface for statistics is not available
+For some reason, no session to the statistics module is available.  This could
+be an error in configuration
 
 % AUTH_SERVER_CREATED   server created
 An informational message indicating that the authoritative server process has
@@ -63,11 +67,21 @@ to the statistics process.
 A debug message indicating that the authoritative server has established
 communication over the previously created statistics channel.
 
+% AUTH_STATS_COMMS communication error in sending statistics data: %1
+An error was encountered when the authoritiative server tried to send data
+to the statistics daemon.  The message includes additional information
+describing the reason for the failure.
+
+% AUTH_STATS_TIMEOUT timeout while sending statistics data: %1
+The authoritative server sent data to the statistics daemon but received
+no acknowledgement within the specified time.  The message includes
+additional information describing the reason for the failure.
+
 % AUTH_XFRIN_CHANNEL_CREATED XFRIN session channel created
 A debug message indicating that the authoritative server has created a channel
-to the XFRIN ("Transfer-in") process.
+to the XFRIN (Transfer-in) process.
 
 % AUTH_XFRIN_CHANNEL_ESTABLISHED XFRIN session channel established
 A debug message indicating that the authoritative server has established
-communication over the previously-created channel to the XFRIN ("Transfer-in")
+communication over the previously-created channel to the XFRIN (Transfer-in)
 process.

+ 2 - 2
src/bin/auth/main.cc

@@ -47,7 +47,7 @@
 #include <auth/auth_log.h>
 #include <asiodns/asiodns.h>
 #include <asiolink/asiolink.h>
-#include <log/macros.h>
+
 #include <log/logger_support.h>
 #include <server_common/keyring.h>
 
@@ -198,7 +198,7 @@ main(int argc, char* argv[]) {
             configureAuthServer(*auth_server, config_session->getFullConfig());
             auth_server->updateConfig(ElementPtr());
         } catch (const AuthConfigError& ex) {
-            LOG_ERROR(auth_logger, AUTH_SERVER_CONFIG_FAIL).arg(ex.what());
+            LOG_ERROR(auth_logger, AUTH_CONFIG_LOAD_FAIL).arg(ex.what());
         }
 
         if (uid != NULL) {

+ 6 - 9
src/bin/auth/statistics.cc

@@ -13,6 +13,7 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 #include <auth/statistics.h>
+#include <auth/auth_log.h>
 
 #include <cc/data.h>
 #include <cc/session.h>
@@ -20,6 +21,8 @@
 #include <sstream>
 #include <iostream>
 
+using namespace isc::auth;
+
 // TODO: We need a namespace ("auth_server"?) to hold
 // AuthSrv and AuthCounters.
 
@@ -65,9 +68,7 @@ bool
 AuthCountersImpl::submitStatistics() const {
     if (statistics_session_ == NULL) {
         if (verbose_mode_) {
-            std::cerr << "[b10-auth] "
-                      << "session interface for statistics"
-                      << " is not available" << std::endl;
+            LOG_ERROR(auth_logger, AUTH_NO_STATS_SESSION);
         }
         return (false);
     }
@@ -96,16 +97,12 @@ AuthCountersImpl::submitStatistics() const {
         statistics_session_->group_recvmsg(env, answer, false, seq);
     } catch (const isc::cc::SessionError& ex) {
         if (verbose_mode_) {
-            std::cerr << "[b10-auth] "
-                      << "communication error in sending statistics data: "
-                      << ex.what() << std::endl;
+            LOG_ERROR(auth_logger, AUTH_STATS_COMMS).arg(ex.what());
         }
         return (false);
     } catch (const isc::cc::SessionTimeout& ex) {
         if (verbose_mode_) {
-            std::cerr << "[b10-auth] "
-                      << "timeout happened while sending statistics data: "
-                      << ex.what() << std::endl;
+            LOG_ERROR(auth_logger, AUTH_STATS_TIMEOUT).arg(ex.what());
         }
         return (false);
     }

+ 4 - 0
src/bin/auth/tests/Makefile.am

@@ -22,6 +22,7 @@ TESTS += run_unittests
 run_unittests_SOURCES = $(top_srcdir)/src/lib/dns/tests/unittest_util.h
 run_unittests_SOURCES += $(top_srcdir)/src/lib/dns/tests/unittest_util.cc
 run_unittests_SOURCES += ../auth_srv.h ../auth_srv.cc
+run_unittests_SOURCES += ../auth_log.h ../auth_log.cc
 run_unittests_SOURCES += ../query.h ../query.cc
 run_unittests_SOURCES += ../change_user.h ../change_user.cc
 run_unittests_SOURCES += ../auth_config.h ../auth_config.cc
@@ -36,6 +37,9 @@ run_unittests_SOURCES += query_unittest.cc
 run_unittests_SOURCES += change_user_unittest.cc
 run_unittests_SOURCES += statistics_unittest.cc
 run_unittests_SOURCES += run_unittests.cc
+
+nodist_run_unittests_SOURCES = ../auth_messages.h ../auth_messages.cc
+
 run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
 run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
 run_unittests_LDADD = $(GTEST_LDADD)