Browse Source

[trac930] modify logging add loggings and new messages for logging
remove unused messages from the message file add test logging names
into unittest scripts

Naoki Kambe 13 years ago
parent
commit
eb4be17ddf

+ 13 - 9
src/bin/stats/stats.py.in

@@ -156,9 +156,7 @@ class Stats:
         Start stats module
         Start stats module
         """
         """
         self.running = True
         self.running = True
-        # TODO: should be added into new logging interface
-        # if self.verbose:
-        #     sys.stdout.write("[b10-stats] starting\n")
+        logger.info(STATS_STARTING)
 
 
         # request Bob to send statistics data
         # request Bob to send statistics data
         logger.debug(DBG_STATS_MESSAGING, STATS_SEND_REQUEST_BOSS)
         logger.debug(DBG_STATS_MESSAGING, STATS_SEND_REQUEST_BOSS)
@@ -289,7 +287,7 @@ class Stats:
         """
         """
         handle show command
         handle show command
         """
         """
-        if (owner or name):
+        if owner or name:
             logger.debug(DBG_STATS_MESSAGING,
             logger.debug(DBG_STATS_MESSAGING,
                          STATS_RECEIVED_SHOW_NAME_COMMAND,
                          STATS_RECEIVED_SHOW_NAME_COMMAND,
                          str(owner)+", "+str(name))
                          str(owner)+", "+str(name))
@@ -314,9 +312,13 @@ class Stats:
         """
         """
         handle show command
         handle show command
         """
         """
-        # TODO: should be added into new logging interface
-        # if self.verbose:
-        #     sys.stdout.write("[b10-stats] 'showschema' command received\n")
+        if owner or name:
+            logger.debug(DBG_STATS_MESSAGING,
+                         STATS_RECEIVED_SHOWSCHEMA_NAME_COMMAND,
+                         str(owner)+", "+str(name))
+        else:
+            logger.debug(DBG_STATS_MESSAGING,
+                         STATS_RECEIVED_SHOWSCHEMA_ALL_COMMAND)
         self.update_modules()
         self.update_modules()
         schema = {}
         schema = {}
         schema_byname = {}
         schema_byname = {}
@@ -372,10 +374,12 @@ if __name__ == "__main__":
         stats.start()
         stats.start()
     except OptionValueError as ove:
     except OptionValueError as ove:
         logger.fatal(STATS_BAD_OPTION_VALUE, ove)
         logger.fatal(STATS_BAD_OPTION_VALUE, ove)
+        sys.exit(1)
     except SessionError as se:
     except SessionError as se:
         logger.fatal(STATS_CC_SESSION_ERROR, se)
         logger.fatal(STATS_CC_SESSION_ERROR, se)
-    # TODO: should be added into new logging interface
+        sys.exit(1)
     except StatsError as se:
     except StatsError as se:
-        sys.exit("[b10-stats] %s" % se)
+        logger.fatal(STATS_START_ERROR, se)
+        sys.exit(1)
     except KeyboardInterrupt as kie:
     except KeyboardInterrupt as kie:
         logger.info(STATS_STOPPED_BY_KEYBOARD)
         logger.info(STATS_STOPPED_BY_KEYBOARD)

+ 1 - 2
src/bin/stats/stats_httpd.py.in

@@ -301,8 +301,7 @@ class StatsHttpd:
             # restore old config
             # restore old config
             self.load_config(old_config)
             self.load_config(old_config)
             self.open_httpd()
             self.open_httpd()
-            return isc.config.ccsession.create_answer(
-                1, "[b10-stats-httpd] %s" % err)
+            return isc.config.ccsession.create_answer(1, str(err))
         else:
         else:
             return isc.config.ccsession.create_answer(0)
             return isc.config.ccsession.create_answer(0)
 
 

+ 11 - 10
src/bin/stats/stats_messages.mes

@@ -28,16 +28,6 @@ control bus. A likely problem is that the message bus daemon
 This debug message is printed when the stats module has received a
 This debug message is printed when the stats module has received a
 configuration update from the configuration manager.
 configuration update from the configuration manager.
 
 
-% STATS_RECEIVED_REMOVE_COMMAND received command to remove %1
-A remove command for the given name was sent to the stats module, and
-the given statistics value will now be removed. It will not appear in
-statistics reports until it appears in a statistics update from a
-module again.
-
-% STATS_RECEIVED_RESET_COMMAND received command to reset all statistics
-The stats module received a command to clear all collected statistics.
-The data is cleared until it receives an update from the modules again.
-
 % STATS_RECEIVED_SHOW_ALL_COMMAND received command to show all statistics
 % STATS_RECEIVED_SHOW_ALL_COMMAND received command to show all statistics
 The stats module received a command to show all statistics that it has
 The stats module received a command to show all statistics that it has
 collected.
 collected.
@@ -72,4 +62,15 @@ installation problem, where the specification file stats.spec is
 from a different version of BIND 10 than the stats module itself.
 from a different version of BIND 10 than the stats module itself.
 Please check your installation.
 Please check your installation.
 
 
+% STATS_STARTING starting
+The stats module will be now starting.
+
+% STATS_RECEIVED_SHOWSCHEMA_ALL_COMMAND received command to show all statistics schema
+The stats module received a command to show all statistics schemas of all modules.
+
+% STATS_RECEIVED_SHOWSCHEMA_NAME_COMMAND received command to show statistics schema for %1
+The stats module received a command to show the specified statistics schema of the specified module.
 
 
+% STATS_START_ERROR stats module error: %1
+An internal error occurred while starting the stats module. The stats
+module will be now shutting down.

+ 3 - 0
src/bin/stats/tests/b10-stats-httpd_test.py

@@ -30,6 +30,9 @@ import stats_httpd
 import stats
 import stats
 from test_utils import BaseModules, ThreadingServerManager, MyStats, MyStatsHttpd, TIMEOUT_SEC
 from test_utils import BaseModules, ThreadingServerManager, MyStats, MyStatsHttpd, TIMEOUT_SEC
 
 
+# set test name for logger 
+isc.log.init("b10-stats-httpd_test")
+
 DUMMY_DATA = {
 DUMMY_DATA = {
     'Boss' : {
     'Boss' : {
         "boot_time": "2011-03-04T11:59:06Z"
         "boot_time": "2011-03-04T11:59:06Z"

+ 3 - 0
src/bin/stats/tests/b10-stats_test.py

@@ -24,6 +24,9 @@ import stats
 import isc.cc.session
 import isc.cc.session
 from test_utils import BaseModules, ThreadingServerManager, MyStats, send_command, TIMEOUT_SEC
 from test_utils import BaseModules, ThreadingServerManager, MyStats, send_command, TIMEOUT_SEC
 
 
+# set test name for logger 
+isc.log.init("b10-stats_test")
+
 class TestUtilties(unittest.TestCase):
 class TestUtilties(unittest.TestCase):
     items = [
     items = [
         { 'item_name': 'test_int1',  'item_type': 'integer', 'item_default': 12345      },
         { 'item_name': 'test_int1',  'item_type': 'integer', 'item_default': 12345      },