From 22b6a39d5dc76ddfbe831ed6f8895f9d1d8de684 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Tue, 28 May 2013 11:31:08 +0100 Subject: [PATCH] Log configuration values on API startup It's very helpful for every service to log its configuration values on startup, so you can e.g. check typos. Also, change the print statements in the API binary to info logs. Change-Id: I1b4181ddc7f36149cddb2c24f514d526c403b2e0 --- bin/ceilometer-api | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bin/ceilometer-api b/bin/ceilometer-api index 06435ba24d..266904c2a5 100755 --- a/bin/ceilometer-api +++ b/bin/ceilometer-api @@ -18,6 +18,7 @@ # under the License. """Set up the development API server. """ +import logging import os import sys from wsgiref import simple_server @@ -28,6 +29,7 @@ from ceilometer.openstack.common import gettextutils gettextutils.install('ceilometer') from ceilometer.api import app +from ceilometer.openstack.common import log from ceilometer import service @@ -43,13 +45,16 @@ if __name__ == '__main__': host, port = '0.0.0.0', int(cfg.CONF.metering_api_port) srv = simple_server.make_server(host, port, root) - print 'Starting server in PID %s' % os.getpid() + LOG = log.getLogger(__name__) + LOG.info('Starting server in PID %s' % os.getpid()) + LOG.info("Configuration:") + cfg.CONF.log_opt_values(LOG, logging.INFO) if host == '0.0.0.0': - print 'serving on 0.0.0.0:%s, view at http://127.0.0.1:%s' % \ - (port, port) + LOG.info('serving on 0.0.0.0:%s, view at http://127.0.0.1:%s' % + (port, port)) else: - print "serving on http://%s:%s" % (host, port) + LOG.info("serving on http://%s:%s" % (host, port)) try: srv.serve_forever()