From: Zhiteng Huang Date: Wed, 13 Mar 2013 05:58:27 +0000 (+0800) Subject: Pull Oslo log fix to enable root logger initialization X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=2b66a382aae3e1c80342feb32549c427677d39c6;p=openstack-build%2Fcinder-build.git Pull Oslo log fix to enable root logger initialization Previous log module in Oslo doesn't initialize root logger, which results in lacking of log message for non-openstack library (such as stevedore). This patch pull latest log module from Oslo, which has recently merged a change to enable root logger initialization. Notice that this change also includes one log modules fix in Oslo which 'unignore' log_format setting. As a result, one may experience log format change when using devstack. To get old log format back, simply assign a NULL string (aka nothing) to 'log_format' configure option in cinder.conf. For example, just append cinder.conf with one new line 'log_format = '. Fix bug: # 1131322 Change-Id: I86396f15ca152512ce6d18d6d424a855b27f495e --- diff --git a/cinder/openstack/common/log.py b/cinder/openstack/common/log.py index 3638b8c98..9f321b946 100644 --- a/cinder/openstack/common/log.py +++ b/cinder/openstack/common/log.py @@ -1,6 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright 2011 OpenStack LLC. +# Copyright 2011 OpenStack Foundation. # Copyright 2010 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. # All Rights Reserved. @@ -47,6 +47,7 @@ from cinder.openstack.common import jsonutils from cinder.openstack.common import local from cinder.openstack.common import notifier + _DEFAULT_LOG_FORMAT = "%(asctime)s %(levelname)8s [%(name)s] %(message)s" _DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S" @@ -324,16 +325,11 @@ def _create_logging_excepthook(product_name): def setup(product_name): """Setup logging.""" - sys.excepthook = _create_logging_excepthook(product_name) - if CONF.log_config: - try: - logging.config.fileConfig(CONF.log_config) - except Exception: - traceback.print_exc() - raise + logging.config.fileConfig(CONF.log_config) else: - _setup_logging_from_conf(product_name) + _setup_logging_from_conf() + sys.excepthook = _create_logging_excepthook(product_name) def set_defaults(logging_context_format_string): @@ -366,8 +362,8 @@ def _find_facility_from_conf(): return facility -def _setup_logging_from_conf(product_name): - log_root = getLogger(product_name).logger +def _setup_logging_from_conf(): + log_root = getLogger(None).logger for handler in log_root.handlers: log_root.removeHandler(handler) @@ -405,7 +401,8 @@ def _setup_logging_from_conf(product_name): if CONF.log_format: handler.setFormatter(logging.Formatter(fmt=CONF.log_format, datefmt=datefmt)) - handler.setFormatter(LegacyFormatter(datefmt=datefmt)) + else: + handler.setFormatter(LegacyFormatter(datefmt=datefmt)) if CONF.debug: log_root.setLevel(logging.DEBUG)