diff options
author | Sean Dague <sdague@linux.vnet.ibm.com> | 2012-11-02 09:15:58 -0400 |
---|---|---|
committer | Sean Dague <sdague@linux.vnet.ibm.com> | 2012-11-02 09:15:58 -0400 |
commit | df0ca59607d0511573cb15fe69bd4dbc5e505a80 (patch) | |
tree | 43b4ea3e01e8219e944f5f6674d933accb03de2d /nova/openstack | |
parent | 8eb367ab65cab8a26c4d61e1e4951e8bb58606b0 (diff) | |
download | nova-df0ca59607d0511573cb15fe69bd4dbc5e505a80.tar.gz nova-df0ca59607d0511573cb15fe69bd4dbc5e505a80.tar.xz nova-df0ca59607d0511573cb15fe69bd4dbc5e505a80.zip |
sync deprecated log method from openstack-common
the nova common deprecated util is now part of openstack-common
log class as a deprecate method. Sync openstack-common and remove
nova common util. All the deprecated pieces from folsom appear
to have already been removed, so no additional code changes needed
for this.
Change-Id: I9cbd6a67c30567cd7002e8e7fec93cfc209787fc
Diffstat (limited to 'nova/openstack')
-rw-r--r-- | nova/openstack/common/log.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/nova/openstack/common/log.py b/nova/openstack/common/log.py index 35c7972c8..67a06a7af 100644 --- a/nova/openstack/common/log.py +++ b/nova/openstack/common/log.py @@ -76,6 +76,9 @@ log_opts = [ cfg.BoolOpt('publish_errors', default=False, help='publish error events'), + cfg.BoolOpt('fatal_deprecations', + default=False, + help='make deprecations fatal'), # NOTE(mikal): there are two options here because sometimes we are handed # a full instance (and could include more information), and other times we @@ -170,6 +173,14 @@ class ContextAdapter(logging.LoggerAdapter): def audit(self, msg, *args, **kwargs): self.log(logging.AUDIT, msg, *args, **kwargs) + def deprecated(self, msg, *args, **kwargs): + stdmsg = _("Deprecated Config: %s") % msg + if CONF.fatal_deprecations: + self.critical(stdmsg, *args, **kwargs) + raise DeprecatedConfig(msg=stdmsg) + else: + self.warn(stdmsg, *args, **kwargs) + def process(self, msg, kwargs): if 'extra' not in kwargs: kwargs['extra'] = {} @@ -450,3 +461,10 @@ class ColorHandler(logging.StreamHandler): def format(self, record): record.color = self.LEVEL_COLORS[record.levelno] return logging.StreamHandler.format(self, record) + + +class DeprecatedConfig(Exception): + message = _("Fatal call to deprecated config: %(msg)s") + + def __init__(self, msg): + super(Exception, self).__init__(self.message % dict(msg=msg)) |