From 8dd6cd5850d3dde7375414e98c3296708923a3c3 Mon Sep 17 00:00:00 2001 From: yfzhao Date: Fri, 24 Mar 2017 16:47:05 +0800 Subject: [PATCH] Remove log translations in others 5/5 Log messages are no longer being translated. This removes all use of the _LE, _LI, and _LW translation markers to simplify logging and to avoid confusion with new contributions. This is the 5/5 commit. Old commit will be abandoned: https://review.openstack.org/#/c/447822/ See: http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html Change-Id: Ifebf6bf1ab8280c3ad3c573ae3772624bf47b461 Depends-On: I9fd264a443c634465b8548067f86ac14c1a51faa Partial-Bug: #1674542 --- manila/coordination.py | 22 +++++++++---------- manila/exception.py | 5 ++--- manila/i18n.py | 10 --------- manila/quota.py | 5 ++--- manila/service.py | 19 ++++++++-------- .../drivers/dell_emc/plugins/vnx/utils.py | 5 ++--- manila/wsgi.py | 12 +++++----- 7 files changed, 32 insertions(+), 46 deletions(-) diff --git a/manila/coordination.py b/manila/coordination.py index a1d4af2991..42157f590e 100644 --- a/manila/coordination.py +++ b/manila/coordination.py @@ -27,7 +27,7 @@ from tooz import coordination from tooz import locking from manila import exception -from manila.i18n import _, _LE, _LI, _LW +from manila.i18n import _ LOG = log.getLogger(__name__) @@ -95,9 +95,9 @@ class Coordinator(object): LOG.debug("This tooz lock management back end does not " "support heart beats.") except coordination.ToozError: - LOG.exception(_LE('Error starting coordination back end.')) + LOG.exception('Error starting coordination back end.') raise - LOG.info(_LI('Coordination back end started successfully.')) + LOG.info('Coordination back end started successfully.') def stop(self): """Disconnect from coordination back end and stop heartbeat.""" @@ -160,16 +160,16 @@ class Coordinator(object): try: self.coordinator.heartbeat() except coordination.ToozConnectionError: - LOG.exception(_LE('Connection error while sending a heartbeat ' - 'to coordination back end.')) + LOG.exception('Connection error while sending a heartbeat ' + 'to coordination back end.') raise except coordination.ToozError: - LOG.exception(_LE('Error sending a heartbeat to coordination ' - 'back end.')) + LOG.exception('Error sending a heartbeat to coordination ' + 'back end.') def _reconnect(self): """Reconnect with jittered exponential back off.""" - LOG.info(_LI('Reconnecting to coordination back end.')) + LOG.info('Reconnecting to coordination back end.') cap = cfg.CONF.coordination.max_reconnect_backoff backoff = base = cfg.CONF.coordination.initial_reconnect_backoff for attempt in itertools.count(1): @@ -178,11 +178,11 @@ class Coordinator(object): break except coordination.ToozError: backoff = min(cap, random.uniform(base, backoff * 3)) - msg = _LW('Reconnect attempt %(attempt)s failed. ' - 'Next try in %(backoff).2fs.') + msg = ('Reconnect attempt %(attempt)s failed. ' + 'Next try in %(backoff).2fs.') LOG.warning(msg, {'attempt': attempt, 'backoff': backoff}) eventlet.sleep(backoff) - LOG.info(_LI('Reconnected to coordination back end.')) + LOG.info('Reconnected to coordination back end.') LOCK_COORDINATOR = Coordinator(prefix='manila-') diff --git a/manila/exception.py b/manila/exception.py index 82bdf6cac6..d23d63a649 100644 --- a/manila/exception.py +++ b/manila/exception.py @@ -30,7 +30,6 @@ import six import webob.exc from manila.i18n import _ -from manila.i18n import _LE LOG = log.getLogger(__name__) @@ -92,9 +91,9 @@ class ManilaException(Exception): except Exception: # kwargs doesn't match a variable in the message # log the issue and the kwargs - LOG.exception(_LE('Exception in string format operation.')) + LOG.exception('Exception in string format operation.') for name, value in kwargs.items(): - LOG.error(_LE("%(name)s: %(value)s"), { + LOG.error("%(name)s: %(value)s", { 'name': name, 'value': value}) if CONF.fatal_exception_format_errors: raise diff --git a/manila/i18n.py b/manila/i18n.py index 6c4169ec1c..8f7cb68205 100644 --- a/manila/i18n.py +++ b/manila/i18n.py @@ -27,16 +27,6 @@ _translators = oslo_i18n.TranslatorFactory(domain=DOMAIN) # The primary translation function using the well-known name "_" _ = _translators.primary -# Translators for log levels. -# -# The abbreviated names are meant to reflect the usual use of a short -# name like '_'. The "L" is for "log" and the other letter comes from -# the level. -_LI = _translators.log_info -_LW = _translators.log_warning -_LE = _translators.log_error -_LC = _translators.log_critical - def enable_lazy(): return oslo_i18n.enable_lazy() diff --git a/manila/quota.py b/manila/quota.py index 682c768d73..26123395f9 100644 --- a/manila/quota.py +++ b/manila/quota.py @@ -26,7 +26,6 @@ import six from manila import db from manila import exception -from manila.i18n import _LE LOG = log.getLogger(__name__) @@ -988,7 +987,7 @@ class QuotaEngine(object): # usage resynchronization and the reservation expiration # mechanisms will resolve the issue. The exception is # logged, however, because this is less than optimal. - LOG.exception(_LE("Failed to commit reservations %s"), + LOG.exception("Failed to commit reservations %s", reservations) return LOG.debug("Committed reservations %s", reservations) @@ -1012,7 +1011,7 @@ class QuotaEngine(object): # usage resynchronization and the reservation expiration # mechanisms will resolve the issue. The exception is # logged, however, because this is less than optimal. - LOG.exception(_LE("Failed to roll back reservations %s"), + LOG.exception("Failed to roll back reservations %s", reservations) return LOG.debug("Rolled back reservations %s", reservations) diff --git a/manila/service.py b/manila/service.py index 8382333e31..7687f9d556 100644 --- a/manila/service.py +++ b/manila/service.py @@ -32,7 +32,6 @@ from manila import context from manila import coordination from manila import db from manila import exception -from manila.i18n import _, _LE, _LI, _LW from manila import rpc from manila import version from manila import wsgi @@ -98,7 +97,7 @@ class Service(service.Service): def start(self): version_string = version.version_string() - LOG.info(_LI('Starting %(topic)s node (version %(version_string)s)'), + LOG.info('Starting %(topic)s node (version %(version_string)s)', {'topic': self.topic, 'version_string': version_string}) self.model_disconnected = False ctxt = context.get_admin_context() @@ -201,7 +200,7 @@ class Service(service.Service): try: db.service_destroy(context.get_admin_context(), self.service_id) except exception.NotFound: - LOG.warning(_LW('Service killed that has no database entry.')) + LOG.warning('Service killed that has no database entry.') def stop(self): # Try to shut the connection down, but if we get any sort of @@ -219,8 +218,8 @@ class Service(service.Service): try: coordination.LOCK_COORDINATOR.stop() except Exception: - LOG.exception(_LE("Unable to stop the Tooz Locking " - "Coordinator.")) + LOG.exception("Unable to stop the Tooz Locking " + "Coordinator.") self.timers = [] @@ -262,13 +261,13 @@ class Service(service.Service): # TODO(termie): make this pattern be more elegant. if getattr(self, 'model_disconnected', False): self.model_disconnected = False - LOG.error(_LE('Recovered model server connection!')) + LOG.error('Recovered model server connection!') # TODO(vish): this should probably only catch connection errors except Exception: # pylint: disable=W0702 if not getattr(self, 'model_disconnected', False): self.model_disconnected = True - LOG.exception(_LE('model server went away')) + LOG.exception('model server went away') class WSGIService(service.ServiceBase): @@ -293,8 +292,8 @@ class WSGIService(service.ServiceBase): self.workers = getattr(CONF, '%s_workers' % name, None) if self.workers is not None and self.workers < 1: LOG.warning( - _LW("Value of config option %(name)s_workers must be integer " - "greater than 1. Input value ignored.") % {'name': name}) + "Value of config option %(name)s_workers must be integer " + "greater than 1. Input value ignored." % {'name': name}) # Reset workers to default self.workers = None self.server = wsgi.Server(name, @@ -374,7 +373,7 @@ _launcher = None def serve(server, workers=None): global _launcher if _launcher: - raise RuntimeError(_('serve() can only be called once')) + raise RuntimeError('serve() can only be called once') _launcher = service.launch(CONF, server, workers=workers) diff --git a/manila/share/drivers/dell_emc/plugins/vnx/utils.py b/manila/share/drivers/dell_emc/plugins/vnx/utils.py index dfc07f6c7a..3bcd7f6901 100644 --- a/manila/share/drivers/dell_emc/plugins/vnx/utils.py +++ b/manila/share/drivers/dell_emc/plugins/vnx/utils.py @@ -15,7 +15,6 @@ import types -from manila.i18n import _LW from oslo_config import cfg from oslo_log import log from oslo_utils import fnmatch @@ -100,7 +99,7 @@ def create_ssl_context(configuration): context.check_hostname = False context.verify_mode = ssl.CERT_NONE except AttributeError: - LOG.warning(_LW('Creating ssl context is not supported on this ' - 'version of Python, ssl verification is disabled.')) + LOG.warning('Creating ssl context is not supported on this ' + 'version of Python, ssl verification is disabled.') context = None return context diff --git a/manila/wsgi.py b/manila/wsgi.py index b9a9db49c9..69c8463a76 100644 --- a/manila/wsgi.py +++ b/manila/wsgi.py @@ -41,7 +41,7 @@ import webob.exc from manila.common import config from manila import exception -from manila.i18n import _, _LE, _LI +from manila.i18n import _ socket_opts = [ cfg.IntOpt('backlog', @@ -183,7 +183,7 @@ class Server(service.ServiceBase): {'host': host, 'port': port}) (self._host, self._port) = self._socket.getsockname()[0:2] - LOG.info(_LI("%(name)s listening on %(_host)s:%(_port)s"), + LOG.info("%(name)s listening on %(_host)s:%(_port)s", {'name': self.name, '_host': self._host, '_port': self._port}) def start(self): @@ -231,8 +231,8 @@ class Server(service.ServiceBase): except Exception: with excutils.save_and_reraise_exception(): LOG.error( - _LE("Failed to start %(name)s on %(_host)s:%(_port)s " - "with SSL support."), + ("Failed to start %(name)s on %(_host)s:%(_port)s " + "with SSL support."), {"name": self.name, "_host": self._host, "_port": self._port} ) @@ -267,7 +267,7 @@ class Server(service.ServiceBase): :returns: None """ - LOG.info(_LI("Stopping WSGI server.")) + LOG.info("Stopping WSGI server.") if self._server is not None: # Resize pool to stop new requests from being processed self._pool.resize(0) @@ -286,7 +286,7 @@ class Server(service.ServiceBase): self._pool.waitall() self._server.wait() except greenlet.GreenletExit: - LOG.info(_LI("WSGI server has stopped.")) + LOG.info("WSGI server has stopped.") def reset(self): """Reset server greenpool size to default.