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
This commit is contained in:
yfzhao 2017-03-24 16:47:05 +08:00 committed by Goutham Pacha Ravi
parent eaa22371cb
commit 8dd6cd5850
7 changed files with 32 additions and 46 deletions

View File

@ -27,7 +27,7 @@ from tooz import coordination
from tooz import locking from tooz import locking
from manila import exception from manila import exception
from manila.i18n import _, _LE, _LI, _LW from manila.i18n import _
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
@ -95,9 +95,9 @@ class Coordinator(object):
LOG.debug("This tooz lock management back end does not " LOG.debug("This tooz lock management back end does not "
"support heart beats.") "support heart beats.")
except coordination.ToozError: except coordination.ToozError:
LOG.exception(_LE('Error starting coordination back end.')) LOG.exception('Error starting coordination back end.')
raise raise
LOG.info(_LI('Coordination back end started successfully.')) LOG.info('Coordination back end started successfully.')
def stop(self): def stop(self):
"""Disconnect from coordination back end and stop heartbeat.""" """Disconnect from coordination back end and stop heartbeat."""
@ -160,16 +160,16 @@ class Coordinator(object):
try: try:
self.coordinator.heartbeat() self.coordinator.heartbeat()
except coordination.ToozConnectionError: except coordination.ToozConnectionError:
LOG.exception(_LE('Connection error while sending a heartbeat ' LOG.exception('Connection error while sending a heartbeat '
'to coordination back end.')) 'to coordination back end.')
raise raise
except coordination.ToozError: except coordination.ToozError:
LOG.exception(_LE('Error sending a heartbeat to coordination ' LOG.exception('Error sending a heartbeat to coordination '
'back end.')) 'back end.')
def _reconnect(self): def _reconnect(self):
"""Reconnect with jittered exponential back off.""" """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 cap = cfg.CONF.coordination.max_reconnect_backoff
backoff = base = cfg.CONF.coordination.initial_reconnect_backoff backoff = base = cfg.CONF.coordination.initial_reconnect_backoff
for attempt in itertools.count(1): for attempt in itertools.count(1):
@ -178,11 +178,11 @@ class Coordinator(object):
break break
except coordination.ToozError: except coordination.ToozError:
backoff = min(cap, random.uniform(base, backoff * 3)) backoff = min(cap, random.uniform(base, backoff * 3))
msg = _LW('Reconnect attempt %(attempt)s failed. ' msg = ('Reconnect attempt %(attempt)s failed. '
'Next try in %(backoff).2fs.') 'Next try in %(backoff).2fs.')
LOG.warning(msg, {'attempt': attempt, 'backoff': backoff}) LOG.warning(msg, {'attempt': attempt, 'backoff': backoff})
eventlet.sleep(backoff) eventlet.sleep(backoff)
LOG.info(_LI('Reconnected to coordination back end.')) LOG.info('Reconnected to coordination back end.')
LOCK_COORDINATOR = Coordinator(prefix='manila-') LOCK_COORDINATOR = Coordinator(prefix='manila-')

View File

@ -30,7 +30,6 @@ import six
import webob.exc import webob.exc
from manila.i18n import _ from manila.i18n import _
from manila.i18n import _LE
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
@ -92,9 +91,9 @@ class ManilaException(Exception):
except Exception: except Exception:
# kwargs doesn't match a variable in the message # kwargs doesn't match a variable in the message
# log the issue and the kwargs # 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(): for name, value in kwargs.items():
LOG.error(_LE("%(name)s: %(value)s"), { LOG.error("%(name)s: %(value)s", {
'name': name, 'value': value}) 'name': name, 'value': value})
if CONF.fatal_exception_format_errors: if CONF.fatal_exception_format_errors:
raise raise

View File

@ -27,16 +27,6 @@ _translators = oslo_i18n.TranslatorFactory(domain=DOMAIN)
# The primary translation function using the well-known name "_" # The primary translation function using the well-known name "_"
_ = _translators.primary _ = _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(): def enable_lazy():
return oslo_i18n.enable_lazy() return oslo_i18n.enable_lazy()

View File

@ -26,7 +26,6 @@ import six
from manila import db from manila import db
from manila import exception from manila import exception
from manila.i18n import _LE
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
@ -988,7 +987,7 @@ class QuotaEngine(object):
# usage resynchronization and the reservation expiration # usage resynchronization and the reservation expiration
# mechanisms will resolve the issue. The exception is # mechanisms will resolve the issue. The exception is
# logged, however, because this is less than optimal. # logged, however, because this is less than optimal.
LOG.exception(_LE("Failed to commit reservations %s"), LOG.exception("Failed to commit reservations %s",
reservations) reservations)
return return
LOG.debug("Committed reservations %s", reservations) LOG.debug("Committed reservations %s", reservations)
@ -1012,7 +1011,7 @@ class QuotaEngine(object):
# usage resynchronization and the reservation expiration # usage resynchronization and the reservation expiration
# mechanisms will resolve the issue. The exception is # mechanisms will resolve the issue. The exception is
# logged, however, because this is less than optimal. # 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) reservations)
return return
LOG.debug("Rolled back reservations %s", reservations) LOG.debug("Rolled back reservations %s", reservations)

View File

@ -32,7 +32,6 @@ from manila import context
from manila import coordination from manila import coordination
from manila import db from manila import db
from manila import exception from manila import exception
from manila.i18n import _, _LE, _LI, _LW
from manila import rpc from manila import rpc
from manila import version from manila import version
from manila import wsgi from manila import wsgi
@ -98,7 +97,7 @@ class Service(service.Service):
def start(self): def start(self):
version_string = version.version_string() 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}) {'topic': self.topic, 'version_string': version_string})
self.model_disconnected = False self.model_disconnected = False
ctxt = context.get_admin_context() ctxt = context.get_admin_context()
@ -201,7 +200,7 @@ class Service(service.Service):
try: try:
db.service_destroy(context.get_admin_context(), self.service_id) db.service_destroy(context.get_admin_context(), self.service_id)
except exception.NotFound: 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): def stop(self):
# Try to shut the connection down, but if we get any sort of # Try to shut the connection down, but if we get any sort of
@ -219,8 +218,8 @@ class Service(service.Service):
try: try:
coordination.LOCK_COORDINATOR.stop() coordination.LOCK_COORDINATOR.stop()
except Exception: except Exception:
LOG.exception(_LE("Unable to stop the Tooz Locking " LOG.exception("Unable to stop the Tooz Locking "
"Coordinator.")) "Coordinator.")
self.timers = [] self.timers = []
@ -262,13 +261,13 @@ class Service(service.Service):
# TODO(termie): make this pattern be more elegant. # TODO(termie): make this pattern be more elegant.
if getattr(self, 'model_disconnected', False): if getattr(self, 'model_disconnected', False):
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 # TODO(vish): this should probably only catch connection errors
except Exception: # pylint: disable=W0702 except Exception: # pylint: disable=W0702
if not getattr(self, 'model_disconnected', False): if not getattr(self, 'model_disconnected', False):
self.model_disconnected = True self.model_disconnected = True
LOG.exception(_LE('model server went away')) LOG.exception('model server went away')
class WSGIService(service.ServiceBase): class WSGIService(service.ServiceBase):
@ -293,8 +292,8 @@ class WSGIService(service.ServiceBase):
self.workers = getattr(CONF, '%s_workers' % name, None) self.workers = getattr(CONF, '%s_workers' % name, None)
if self.workers is not None and self.workers < 1: if self.workers is not None and self.workers < 1:
LOG.warning( LOG.warning(
_LW("Value of config option %(name)s_workers must be integer " "Value of config option %(name)s_workers must be integer "
"greater than 1. Input value ignored.") % {'name': name}) "greater than 1. Input value ignored." % {'name': name})
# Reset workers to default # Reset workers to default
self.workers = None self.workers = None
self.server = wsgi.Server(name, self.server = wsgi.Server(name,
@ -374,7 +373,7 @@ _launcher = None
def serve(server, workers=None): def serve(server, workers=None):
global _launcher global _launcher
if _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) _launcher = service.launch(CONF, server, workers=workers)

View File

@ -15,7 +15,6 @@
import types import types
from manila.i18n import _LW
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log from oslo_log import log
from oslo_utils import fnmatch from oslo_utils import fnmatch
@ -100,7 +99,7 @@ def create_ssl_context(configuration):
context.check_hostname = False context.check_hostname = False
context.verify_mode = ssl.CERT_NONE context.verify_mode = ssl.CERT_NONE
except AttributeError: except AttributeError:
LOG.warning(_LW('Creating ssl context is not supported on this ' LOG.warning('Creating ssl context is not supported on this '
'version of Python, ssl verification is disabled.')) 'version of Python, ssl verification is disabled.')
context = None context = None
return context return context

View File

@ -41,7 +41,7 @@ import webob.exc
from manila.common import config from manila.common import config
from manila import exception from manila import exception
from manila.i18n import _, _LE, _LI from manila.i18n import _
socket_opts = [ socket_opts = [
cfg.IntOpt('backlog', cfg.IntOpt('backlog',
@ -183,7 +183,7 @@ class Server(service.ServiceBase):
{'host': host, 'port': port}) {'host': host, 'port': port})
(self._host, self._port) = self._socket.getsockname()[0:2] (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}) {'name': self.name, '_host': self._host, '_port': self._port})
def start(self): def start(self):
@ -231,8 +231,8 @@ class Server(service.ServiceBase):
except Exception: except Exception:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.error( LOG.error(
_LE("Failed to start %(name)s on %(_host)s:%(_port)s " ("Failed to start %(name)s on %(_host)s:%(_port)s "
"with SSL support."), "with SSL support."),
{"name": self.name, "_host": self._host, {"name": self.name, "_host": self._host,
"_port": self._port} "_port": self._port}
) )
@ -267,7 +267,7 @@ class Server(service.ServiceBase):
:returns: None :returns: None
""" """
LOG.info(_LI("Stopping WSGI server.")) LOG.info("Stopping WSGI server.")
if self._server is not None: if self._server is not None:
# Resize pool to stop new requests from being processed # Resize pool to stop new requests from being processed
self._pool.resize(0) self._pool.resize(0)
@ -286,7 +286,7 @@ class Server(service.ServiceBase):
self._pool.waitall() self._pool.waitall()
self._server.wait() self._server.wait()
except greenlet.GreenletExit: except greenlet.GreenletExit:
LOG.info(_LI("WSGI server has stopped.")) LOG.info("WSGI server has stopped.")
def reset(self): def reset(self):
"""Reset server greenpool size to default. """Reset server greenpool size to default.