diff --git a/bin/heat-api b/bin/heat-api index 9261d9507..0fa6f7c78 100755 --- a/bin/heat-api +++ b/bin/heat-api @@ -46,7 +46,12 @@ LOG = logging.getLogger('heat.api') if __name__ == '__main__': try: cfg.CONF(project='heat', prog='heat-api') - config.setup_logging() + cfg.CONF.default_log_levels = ['amqplib=WARN', + 'qpid.messaging=INFO', + 'keystone=INFO', + 'eventlet.wsgi.server=WARN', + ] + logging.setup('heat') app = config.load_paste_app() diff --git a/bin/heat-api-cfn b/bin/heat-api-cfn index d80ac1663..48e9f9d83 100755 --- a/bin/heat-api-cfn +++ b/bin/heat-api-cfn @@ -48,7 +48,12 @@ LOG = logging.getLogger('heat.api.cfn') if __name__ == '__main__': try: cfg.CONF(project='heat', prog='heat-api-cfn') - config.setup_logging() + cfg.CONF.default_log_levels = ['amqplib=WARN', + 'qpid.messaging=INFO', + 'keystone=INFO', + 'eventlet.wsgi.server=WARN', + ] + logging.setup('heat') app = config.load_paste_app() diff --git a/bin/heat-api-cloudwatch b/bin/heat-api-cloudwatch index fe54700a4..acd95bfb4 100755 --- a/bin/heat-api-cloudwatch +++ b/bin/heat-api-cloudwatch @@ -48,7 +48,12 @@ LOG = logging.getLogger('heat.api.cloudwatch') if __name__ == '__main__': try: cfg.CONF(project='heat', prog='heat-api-cloudwatch') - config.setup_logging() + cfg.CONF.default_log_levels = ['amqplib=WARN', + 'qpid.messaging=INFO', + 'keystone=INFO', + 'eventlet.wsgi.server=WARN', + ] + logging.setup('heat') app = config.load_paste_app() diff --git a/bin/heat-engine b/bin/heat-engine index 4396a5d6b..2eefea1d7 100755 --- a/bin/heat-engine +++ b/bin/heat-engine @@ -27,7 +27,6 @@ eventlet.monkey_patch() import os import sys - # If ../heat/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), @@ -47,13 +46,18 @@ from heat.common import config from heat.db import api as db_api -logger = logging.getLogger('heat.engine') +LOG = logging.getLogger('heat.engine') if __name__ == '__main__': cfg.CONF(project='heat', prog='heat-engine') - - config.setup_logging() + cfg.CONF.default_log_levels = ['amqplib=WARN', + 'sqlalchemy=WARN', + 'qpid.messaging=INFO', + 'keystone=INFO', + 'eventlet.wsgi.server=WARN', + ] + logging.setup('heat') from heat.engine import service as engine diff --git a/heat/common/config.py b/heat/common/config.py index 183d64c37..0b433bfeb 100644 --- a/heat/common/config.py +++ b/heat/common/config.py @@ -18,16 +18,15 @@ Routines for configuring Heat """ -import logging -import logging.config -import logging.handlers +import logging as sys_logging import os -import sys from eventlet.green import socket from oslo.config import cfg from heat.common import wsgi + +from heat.openstack.common import log as logging from heat.openstack.common import rpc DEFAULT_PORT = 8000 @@ -128,57 +127,6 @@ def register_engine_opts(): rpc.set_defaults(control_exchange='heat') -def setup_logging(): - """ - Sets up the logging options for a log with supplied name - """ - - if cfg.CONF.log_config: - # Use a logging configuration file for all settings... - if os.path.exists(cfg.CONF.log_config): - logging.config.fileConfig(cfg.CONF.log_config) - return - else: - raise RuntimeError("Unable to locate specified logging " - "config file: %s" % cfg.CONF.log_config) - - root_logger = logging.root - if cfg.CONF.debug: - root_logger.setLevel(logging.DEBUG) - elif cfg.CONF.verbose: - root_logger.setLevel(logging.INFO) - else: - root_logger.setLevel(logging.WARNING) - - # quiet down the qpid logging, without this qpid dumps raw hex stuff - # into our logs, which is generally too low-level to be useful to us - if cfg.CONF.rpc_backend.split('.')[-1] == 'impl_qpid': - root_logger.manager.getLogger('qpid.messaging').setLevel(logging.INFO) - - formatter = logging.Formatter(cfg.CONF.log_format, - cfg.CONF.log_date_format) - - if cfg.CONF.use_syslog: - try: - facility = getattr(logging.handlers.SysLogHandler, - cfg.CONF.syslog_log_facility) - except AttributeError: - raise ValueError(_("Invalid syslog facility")) - - handler = logging.handlers.SysLogHandler(address='/dev/log', - facility=facility) - elif cfg.CONF.log_file: - logfile = cfg.CONF.log_file - if cfg.CONF.log_dir: - logfile = os.path.join(cfg.CONF.log_dir, logfile) - handler = logging.handlers.WatchedFileHandler(logfile) - else: - handler = logging.StreamHandler(sys.stdout) - - handler.setFormatter(formatter) - root_logger.addHandler(handler) - - def _register_paste_deploy_opts(): """ Idempotent registration of paste_deploy option group @@ -244,7 +192,8 @@ def load_paste_app(app_name=None): # Log the options used when starting if we're in debug mode... if cfg.CONF.debug: - cfg.CONF.log_opt_values(logging.getLogger(app_name), logging.DEBUG) + cfg.CONF.log_opt_values(logging.getLogger(app_name), + sys_logging.DEBUG) return app except (LookupError, ImportError), e: