diff --git a/nova/filters.py b/nova/filters.py index f7679e238e86..99f55759d947 100644 --- a/nova/filters.py +++ b/nova/filters.py @@ -19,7 +19,6 @@ Filter support from oslo_log import log as logging -from nova.i18n import _LI from nova import loadables LOG = logging.getLogger(__name__) @@ -96,11 +95,10 @@ class BaseFilterHandler(loadables.BaseLoader): for obj in list_objs] full_filter_results.append((cls_name, remaining)) else: - LOG.info(_LI("Filter %s returned 0 hosts"), cls_name) + LOG.info("Filter %s returned 0 hosts", cls_name) full_filter_results.append((cls_name, None)) break - LOG.debug("Filter %(cls_name)s returned " - "%(obj_len)d host(s)", + LOG.debug("Filter %(cls_name)s returned %(obj_len)d host(s)", {'cls_name': cls_name, 'obj_len': len(list_objs)}) if not list_objs: # Log the filtration history diff --git a/nova/hacking/checks.py b/nova/hacking/checks.py index 5a3409947f42..10f6d8222d27 100644 --- a/nova/hacking/checks.py +++ b/nova/hacking/checks.py @@ -788,8 +788,8 @@ def no_log_warn(logical_line): def check_context_log(logical_line, filename, noqa): """check whether context is being passed to the logs - Not correct: LOG.info(_LI("Rebooting instance"), context=context) - Correct: LOG.info(_LI("Rebooting instance")) + Not correct: LOG.info("Rebooting instance", context=context) + Correct: LOG.info("Rebooting instance") https://bugs.launchpad.net/nova/+bug/1500896 N353 diff --git a/nova/i18n.py b/nova/i18n.py index 57e07072a228..d3bf9ba34988 100644 --- a/nova/i18n.py +++ b/nova/i18n.py @@ -27,13 +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 - def translate(value, user_locale): return oslo_i18n.translate(value, user_locale) diff --git a/nova/service.py b/nova/service.py index c618cf6da7fa..fd28a7174016 100644 --- a/nova/service.py +++ b/nova/service.py @@ -34,7 +34,7 @@ import nova.conf from nova import context from nova import debugger from nova import exception -from nova.i18n import _, _LI +from nova.i18n import _ from nova import objects from nova.objects import base as objects_base from nova.objects import service as service_obj @@ -71,8 +71,8 @@ def _create_service_ref(this_service, context): def _update_service_ref(service): if service.version != service_obj.SERVICE_VERSION: - LOG.info(_LI('Updating service version for %(binary)s on ' - '%(host)s from %(old)i to %(new)i'), + LOG.info('Updating service version for %(binary)s on ' + '%(host)s from %(old)i to %(new)i', {'binary': service.binary, 'host': service.host, 'old': service.version, @@ -89,7 +89,7 @@ def setup_profiler(binary, host): project="nova", service=binary, host=host) - LOG.info(_LI("OSProfiler is enabled.")) + LOG.info("OSProfiler is enabled.") def assert_eventlet_uses_monotonic_clock(): @@ -166,7 +166,7 @@ class Service(service.Service): assert_eventlet_uses_monotonic_clock() verstr = version.version_string_with_package() - LOG.info(_LI('Starting %(topic)s node (version %(version)s)'), + LOG.info('Starting %(topic)s node (version %(version)s)', {'topic': self.topic, 'version': verstr}) self.basic_config_check() self.manager.init_host() diff --git a/nova/servicegroup/drivers/db.py b/nova/servicegroup/drivers/db.py index 811bf9503954..1b6c35eb54ee 100644 --- a/nova/servicegroup/drivers/db.py +++ b/nova/servicegroup/drivers/db.py @@ -20,7 +20,7 @@ import six import nova.conf from nova import exception -from nova.i18n import _, _LI +from nova.i18n import _ from nova.servicegroup import api from nova.servicegroup.drivers import base @@ -95,8 +95,7 @@ class DbDriver(base.Driver): # TODO(termie): make this pattern be more elegant. if getattr(service, 'model_disconnected', False): service.model_disconnected = False - LOG.info( - _LI('Recovered from being unable to report status.')) + LOG.info('Recovered from being unable to report status.') except messaging.MessagingTimeout: # NOTE(johngarbutt) during upgrade we will see messaging timeouts # as nova-conductor is restarted, so only log this error once. diff --git a/nova/servicegroup/drivers/mc.py b/nova/servicegroup/drivers/mc.py index ea86cb26845b..24a66522f8a7 100644 --- a/nova/servicegroup/drivers/mc.py +++ b/nova/servicegroup/drivers/mc.py @@ -23,7 +23,7 @@ from oslo_utils import timeutils from nova import cache_utils import nova.conf -from nova.i18n import _, _LI +from nova.i18n import _ from nova.servicegroup import api from nova.servicegroup.drivers import base @@ -101,8 +101,9 @@ class MemcachedDriver(base.Driver): if getattr(service, 'model_disconnected', False): service.model_disconnected = False LOG.info( - _LI('Recovered connection to memcache server ' - 'for reporting service status.')) + 'Recovered connection to memcache server for reporting ' + 'service status.' + ) # TODO(vish): this should probably only catch connection errors except Exception: diff --git a/nova/tests/unit/test_hacking.py b/nova/tests/unit/test_hacking.py index 8aa304ba1c40..b9f413e52be5 100644 --- a/nova/tests/unit/test_hacking.py +++ b/nova/tests/unit/test_hacking.py @@ -709,22 +709,21 @@ class HackingTestCase(test.NoDBTestCase): def test_log_context(self): code = """ - LOG.info(_LI("Rebooting instance"), - context=context, instance=instance) + LOG.info("Rebooting instance", + context=context, instance=instance) """ errors = [(1, 0, 'N353')] self._assert_has_errors(code, checks.check_context_log, expected_errors=errors) code = """ - LOG.info(_LI("Rebooting instance"), - context=admin_context, instance=instance) + LOG.info("Rebooting instance", + context=admin_context, instance=instance) """ errors = [(1, 0, 'N353')] self._assert_has_errors(code, checks.check_context_log, expected_errors=errors) code = """ - LOG.info(_LI("Rebooting instance"), - instance=instance) + LOG.info("Rebooting instance", instance=instance) """ self._assert_has_no_errors(code, checks.check_context_log) diff --git a/nova/wsgi.py b/nova/wsgi.py index 05437b09f01a..d40b324db482 100644 --- a/nova/wsgi.py +++ b/nova/wsgi.py @@ -30,7 +30,7 @@ from oslo_utils import excutils import nova.conf from nova import exception -from nova.i18n import _, _LI +from nova.i18n import _ from nova import utils CONF = nova.conf.CONF @@ -97,7 +97,7 @@ class Server(service.ServiceBase): raise (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): @@ -202,7 +202,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 @@ -222,4 +222,4 @@ 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.")