Browse Source

[1897] Rename log identifiers STATHTTPD_* to STATSHTTPD_*

Jelte Jansen 12 years ago
parent
commit
09c24690d4

+ 22 - 22
src/bin/stats/stats_httpd.py.in

@@ -43,8 +43,8 @@ isc.log.init("b10-stats-httpd", buffer=True)
 logger = isc.log.Logger("stats-httpd")
 
 # Some constants for debug levels.
-DBG_STATHTTPD_INIT = logger.DBGLVL_START_SHUT
-DBG_STATHTTPD_MESSAGING = logger.DBGLVL_COMMAND
+DBG_STATSHTTPD_INIT = logger.DBGLVL_START_SHUT
+DBG_STATSHTTPD_MESSAGING = logger.DBGLVL_COMMAND
 
 # If B10_FROM_SOURCE is set in the environment, we use data files
 # from a directory relative to that, otherwise we use the ones
@@ -187,11 +187,11 @@ class HttpHandler(http.server.BaseHTTPRequestHandler):
             # Couldn't find neither specified module name nor
             # specified item name
             self.send_error(404)
-            logger.error(STATHTTPD_SERVER_DATAERROR, err)
+            logger.error(STATSHTTPD_SERVER_DATAERROR, err)
             return None
         except Exception as err:
             self.send_error(500)
-            logger.error(STATHTTPD_SERVER_ERROR, err)
+            logger.error(STATSHTTPD_SERVER_ERROR, err)
             return None
         else:
             self.send_response(200)
@@ -205,7 +205,7 @@ class HttpHandler(http.server.BaseHTTPRequestHandler):
         """overrides the parent method log_message()
         to use the bind10 logging framework.
         """
-        logger.debug(DBG_STATHTTPD_MESSAGING, STATHTTPD_HTTPLOG,
+        logger.debug(DBG_STATSHTTPD_MESSAGING, STATSHTTPD_HTTPLOG,
                      self.address_string(),
                      format%args)
 
@@ -271,7 +271,7 @@ class StatsHttpd:
     def open_mccs(self):
         """Opens a ModuleCCSession object"""
         # create ModuleCCSession
-        logger.debug(DBG_STATHTTPD_INIT, STATHTTPD_STARTING_CC_SESSION)
+        logger.debug(DBG_STATSHTTPD_INIT, STATSHTTPD_STARTING_CC_SESSION)
         self.mccs = isc.config.ModuleCCSession(
             SPECFILE_LOCATION, self.config_handler, self.command_handler)
         self.cc_session = self.mccs._session
@@ -282,7 +282,7 @@ class StatsHttpd:
             return
         self.mccs.send_stopping()
 
-        logger.debug(DBG_STATHTTPD_INIT, STATHTTPD_CLOSING_CC_SESSION)
+        logger.debug(DBG_STATSHTTPD_INIT, STATSHTTPD_CLOSING_CC_SESSION)
         self.mccs.close()
         self.mccs = None
 
@@ -325,7 +325,7 @@ class StatsHttpd:
                 server_address, HttpHandler,
                 self.xml_handler, self.xsd_handler, self.xsl_handler,
                 self.write_log)
-            logger.info(STATHTTPD_STARTED, server_address[0],
+            logger.info(STATSHTTPD_STARTED, server_address[0],
                         server_address[1])
             return httpd
         except (socket.gaierror, socket.error,
@@ -341,7 +341,7 @@ class StatsHttpd:
         """Closes sockets for HTTP"""
         while len(self.httpd)>0:
             ht = self.httpd.pop()
-            logger.info(STATHTTPD_CLOSING, ht.server_address[0],
+            logger.info(STATSHTTPD_CLOSING, ht.server_address[0],
                         ht.server_address[1])
             ht.server_close()
 
@@ -377,7 +377,7 @@ class StatsHttpd:
     def stop(self):
         """Stops the running StatsHttpd objects. Closes CC session and
         HTTP handling sockets"""
-        logger.info(STATHTTPD_SHUTDOWN)
+        logger.info(STATSHTTPD_SHUTDOWN)
         self.close_httpd()
         self.close_mccs()
         self.running = False
@@ -395,7 +395,7 @@ class StatsHttpd:
     def config_handler(self, new_config):
         """Config handler for the ModuleCCSession object. It resets
         addresses and ports to listen HTTP requests on."""
-        logger.debug(DBG_STATHTTPD_MESSAGING, STATHTTPD_HANDLE_CONFIG,
+        logger.debug(DBG_STATSHTTPD_MESSAGING, STATSHTTPD_HANDLE_CONFIG,
                    new_config)
         errors = []
         if not self.mccs.get_module_spec().\
@@ -413,7 +413,7 @@ class StatsHttpd:
         try:
             self.open_httpd()
         except HttpServerError as err:
-            logger.error(STATHTTPD_SERVER_ERROR, err)
+            logger.error(STATSHTTPD_SERVER_ERROR, err)
             # restore old config
             self.load_config(old_config)
             self.open_httpd()
@@ -425,18 +425,18 @@ class StatsHttpd:
         """Command handler for the ModuleCCSesson object. It handles
         "status" and "shutdown" commands."""
         if command == "status":
-            logger.debug(DBG_STATHTTPD_MESSAGING,
-                         STATHTTPD_RECEIVED_STATUS_COMMAND)
+            logger.debug(DBG_STATSHTTPD_MESSAGING,
+                         STATSHTTPD_RECEIVED_STATUS_COMMAND)
             return isc.config.ccsession.create_answer(
                 0, "Stats Httpd is up. (PID " + str(os.getpid()) + ")")
         elif command == "shutdown":
-            logger.debug(DBG_STATHTTPD_MESSAGING,
-                         STATHTTPD_RECEIVED_SHUTDOWN_COMMAND)
+            logger.debug(DBG_STATSHTTPD_MESSAGING,
+                         STATSHTTPD_RECEIVED_SHUTDOWN_COMMAND)
             self.running = False
             return isc.config.ccsession.create_answer(0)
         else:
-            logger.debug(DBG_STATHTTPD_MESSAGING,
-                         STATHTTPD_RECEIVED_UNKNOWN_COMMAND, command)
+            logger.debug(DBG_STATSHTTPD_MESSAGING,
+                         STATSHTTPD_RECEIVED_UNKNOWN_COMMAND, command)
             return isc.config.ccsession.create_answer(
                 1, "Unknown command: " + str(command))
 
@@ -621,13 +621,13 @@ if __name__ == "__main__":
         stats_httpd = StatsHttpd()
         stats_httpd.start()
     except OptionValueError as ove:
-        logger.fatal(STATHTTPD_BAD_OPTION_VALUE, ove)
+        logger.fatal(STATSHTTPD_BAD_OPTION_VALUE, ove)
         sys.exit(1)
     except isc.cc.session.SessionError as se:
-        logger.fatal(STATHTTPD_CC_SESSION_ERROR, se)
+        logger.fatal(STATSHTTPD_CC_SESSION_ERROR, se)
         sys.exit(1)
     except HttpServerError as hse:
-        logger.fatal(STATHTTPD_START_SERVER_INIT_ERROR, hse)
+        logger.fatal(STATSHTTPD_START_SERVER_INIT_ERROR, hse)
         sys.exit(1)
     except KeyboardInterrupt as kie:
-        logger.info(STATHTTPD_STOPPED_BY_KEYBOARD)
+        logger.info(STATSHTTPD_STOPPED_BY_KEYBOARD)

+ 18 - 18
src/bin/stats/stats_httpd_messages.mes

@@ -15,81 +15,81 @@
 # No namespace declaration - these constants go in the global namespace
 # of the stats_httpd_messages python module.
 
-% STATHTTPD_BAD_OPTION_VALUE bad command line argument: %1
+% STATSHTTPD_BAD_OPTION_VALUE bad command line argument: %1
 The stats-httpd module was called with a bad command-line argument
 and will not start.
 
-% STATHTTPD_CC_SESSION_ERROR error connecting to message bus: %1
+% STATSHTTPD_CC_SESSION_ERROR error connecting to message bus: %1
 The stats-httpd module was unable to connect to the BIND 10 command
 and control bus. A likely problem is that the message bus daemon
 (b10-msgq) is not running. The stats-httpd module will now shut down.
 
-% STATHTTPD_CLOSING closing %1#%2
+% STATSHTTPD_CLOSING closing %1#%2
 The stats-httpd daemon will stop listening for requests on the given
 address and port number.
 
-% STATHTTPD_CLOSING_CC_SESSION stopping cc session
+% STATSHTTPD_CLOSING_CC_SESSION stopping cc session
 Debug message indicating that the stats-httpd module is disconnecting
 from the command and control bus.
 
-% STATHTTPD_HANDLE_CONFIG reading configuration: %1
+% STATSHTTPD_HANDLE_CONFIG reading configuration: %1
 The stats-httpd daemon has received new configuration data and will now
 process it. The (changed) data is printed.
 
-% STATHTTPD_RECEIVED_SHUTDOWN_COMMAND shutdown command received
+% STATSHTTPD_RECEIVED_SHUTDOWN_COMMAND shutdown command received
 A shutdown command was sent to the stats-httpd module, and it will
 now shut down.
 
-% STATHTTPD_RECEIVED_STATUS_COMMAND received command to return status
+% STATSHTTPD_RECEIVED_STATUS_COMMAND received command to return status
 A status command was sent to the stats-httpd module, and it will
 respond with 'Stats Httpd is up.' and its PID.
 
-% STATHTTPD_RECEIVED_UNKNOWN_COMMAND received unknown command: %1
+% STATSHTTPD_RECEIVED_UNKNOWN_COMMAND received unknown command: %1
 An unknown command has been sent to the stats-httpd module. The
 stats-httpd module will respond with an error, and the command will
 be ignored.
 
-% STATHTTPD_SERVER_DATAERROR HTTP server data error: %1
+% STATSHTTPD_SERVER_DATAERROR HTTP server data error: %1
 An internal error occurred while handling an HTTP request. An HTTP 404
 response will be sent back, and the specific error is printed. This
 is an error condition that likely points the specified data
 corresponding to the requested URI is incorrect.
 
-% STATHTTPD_SERVER_ERROR HTTP server error: %1
+% STATSHTTPD_SERVER_ERROR HTTP server error: %1
 An internal error occurred while handling an HTTP request. An HTTP 500
 response will be sent back, and the specific error is printed. This
 is an error condition that likely points to a module that is not
 responding correctly to statistic requests.
 
-% STATHTTPD_SERVER_INIT_ERROR HTTP server initialization error: %1
+% STATSHTTPD_SERVER_INIT_ERROR HTTP server initialization error: %1
 There was a problem initializing the HTTP server in the stats-httpd
 module upon receiving its configuration data. The most likely cause
 is a port binding problem or a bad configuration value. The specific
 error is printed in the message. The new configuration is ignored,
 and an error is sent back.
 
-% STATHTTPD_SHUTDOWN shutting down
+% STATSHTTPD_SHUTDOWN shutting down
 The stats-httpd daemon is shutting down.
 
-% STATHTTPD_STARTED listening on %1#%2
+% STATSHTTPD_STARTED listening on %1#%2
 The stats-httpd daemon will now start listening for requests on the
 given address and port number.
 
-% STATHTTPD_STARTING_CC_SESSION starting cc session
+% STATSHTTPD_STARTING_CC_SESSION starting cc session
 Debug message indicating that the stats-httpd module is connecting to
 the command and control bus.
 
-% STATHTTPD_START_SERVER_INIT_ERROR HTTP server initialization error: %1
+% STATSHTTPD_START_SERVER_INIT_ERROR HTTP server initialization error: %1
 There was a problem initializing the HTTP server in the stats-httpd
 module upon startup. The most likely cause is that it was not able
 to bind to the listening port. The specific error is printed, and the
 module will shut down.
 
-% STATHTTPD_STOPPED_BY_KEYBOARD keyboard interrupt, shutting down
+% STATSHTTPD_STOPPED_BY_KEYBOARD keyboard interrupt, shutting down
 There was a keyboard interrupt signal to stop the stats-httpd
 daemon. The daemon will now shut down.
 
-% STATHTTPD_UNKNOWN_CONFIG_ITEM unknown configuration item: %1
+% STATSHTTPD_UNKNOWN_CONFIG_ITEM unknown configuration item: %1
 The stats-httpd daemon received a configuration update from the
 configuration manager. However, one of the items in the
 configuration is unknown. The new configuration is ignored, and an
@@ -97,7 +97,7 @@ error is sent back. As possible cause is that there was an upgrade
 problem, and the stats-httpd version is out of sync with the rest of
 the system.
 
-% STATHTTPD_HTTPLOG %1 %2
+% STATSHTTPD_HTTPLOG %1 %2
 Debug HTTP log message. These are the messages logged by the http server
 instance. For most logs, the message shows HTTP client and query
 information like HTTP method, URI, and status code, but the http server

+ 1 - 1
tests/lettuce/features/stats_httpd.feature

@@ -3,7 +3,7 @@ Feature: b10-stats-httpd module
 
     Scenario: Check that the module logs and responds to requests
     Given I have bind10 running with configuration bindctl_commands.config
-    And wait for bind10 stderr message STATHTTPD_STARTED
+    And wait for bind10 stderr message STATSHTTPD_STARTED
 
     When I request the URL http://127.0.0.1:47811/
     # Should result in redirect, so two query logs