Skip to content

Commit

Permalink
Pull Oslo log fix to enable root logger initialization
Browse files Browse the repository at this point in the history
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
(cherry picked from commit 2b66a38)
  • Loading branch information
zhiteng authored and j-griffith committed Mar 22, 2013
1 parent 36e4e85 commit 6af4d65
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions 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.
Expand Down Expand Up @@ -47,6 +47,7 @@
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"

Expand Down Expand Up @@ -324,16 +325,11 @@ def logging_excepthook(type, value, tb):

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):
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6af4d65

Please sign in to comment.