diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-11-02 22:58:29 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-11-02 22:58:29 +0000 |
| commit | 3ee98a751fc9a9cc5a28b8290a4f7bdd16937b2f (patch) | |
| tree | 4feb78cc2f00e45536aadb265854290c06193a93 /nova/openstack | |
| parent | 8a6e725501896149dea24a816e126f665b823074 (diff) | |
| parent | df0ca59607d0511573cb15fe69bd4dbc5e505a80 (diff) | |
| download | nova-3ee98a751fc9a9cc5a28b8290a4f7bdd16937b2f.tar.gz nova-3ee98a751fc9a9cc5a28b8290a4f7bdd16937b2f.tar.xz nova-3ee98a751fc9a9cc5a28b8290a4f7bdd16937b2f.zip | |
Merge "sync deprecated log method from openstack-common"
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)) |
