From 442b78f5286de8a267fc8ec268406cc2c1280535 Mon Sep 17 00:00:00 2001 From: Gary Kotton Date: Wed, 30 Apr 2014 04:15:41 -0700 Subject: [PATCH] Don't translate debug level logs in nova.spice, storage, tests and vnc Our translation policy (https://wiki.openstack.org/wiki/LoggingStandards#Log_Translation) calls for not translating debug level logs. This is to help prioritize log translation. Furthermore translation has a performance overhead, even if the log isn't used (since nova doesn't support lazy translation yet). Change-Id: I5964d2f6a4328b91d67c0d8fd514e1eb7c6048bb --- nova/hacking/checks.py | 4 ++++ nova/storage/linuxscsi.py | 6 +++--- nova/tests/fake_processutils.py | 11 +++++------ nova/tests/integrated/api/client.py | 6 +++--- nova/tests/integrated/test_login.py | 3 +-- nova/tests/virt/xenapi/test_xenapi.py | 5 ++--- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/nova/hacking/checks.py b/nova/hacking/checks.py index c0d1368adf..77ae669c49 100644 --- a/nova/hacking/checks.py +++ b/nova/hacking/checks.py @@ -228,6 +228,10 @@ def no_translate_debug_logs(logical_line, filename): "nova/pci", "nova/rdp", "nova/servicegroup", + "nova/spice", + "nova/storage", + "nova/tests", + "nova/vnc", ] if max([name in filename for name in dirs]): if logical_line.startswith("LOG.debug(_("): diff --git a/nova/storage/linuxscsi.py b/nova/storage/linuxscsi.py index 371656ad32..09669fa565 100644 --- a/nova/storage/linuxscsi.py +++ b/nova/storage/linuxscsi.py @@ -67,8 +67,8 @@ def get_device_info(device): def _wait_for_remove(device, tries): tries = tries + 1 - LOG.debug(_("Trying (%(tries)s) to remove device %(device)s") - % {'tries': tries, 'device': device["device"]}) + LOG.debug("Trying (%(tries)s) to remove device %(device)s", + {'tries': tries, 'device': device["device"]}) path = "/sys/bus/scsi/drivers/sd/%s:%s:%s:%s/delete" echo_scsi_command(path % (device["host"], device["channel"], @@ -121,7 +121,7 @@ def find_multipath_device(device): LOG.warn(_("Couldn't find multipath device %s"), line) return None - LOG.debug(_("Found multipath device = %s"), mdev) + LOG.debug("Found multipath device = %s", mdev) device_lines = lines[3:] for dev_line in device_lines: if dev_line.find("policy") != -1: diff --git a/nova/tests/fake_processutils.py b/nova/tests/fake_processutils.py index 37fb367ac4..7d7b4c23b4 100644 --- a/nova/tests/fake_processutils.py +++ b/nova/tests/fake_processutils.py @@ -19,7 +19,6 @@ import re from eventlet import greenthread import six -from nova.openstack.common.gettextutils import _ from nova.openstack.common import log as logging from nova.openstack.common import processutils @@ -68,7 +67,7 @@ def fake_execute(*cmd_parts, **kwargs): run_as_root = kwargs.get('run_as_root', False) cmd_str = ' '.join(str(part) for part in cmd_parts) - LOG.debug(_("Faking execution of cmd (subprocess): %s"), cmd_str) + LOG.debug("Faking execution of cmd (subprocess): %s", cmd_str) _fake_execute_log.append(cmd_str) reply_handler = fake_execute_default_reply_handler @@ -76,7 +75,7 @@ def fake_execute(*cmd_parts, **kwargs): for fake_replier in _fake_execute_repliers: if re.match(fake_replier[0], cmd_str): reply_handler = fake_replier[1] - LOG.debug(_('Faked command matched %s') % fake_replier[0]) + LOG.debug('Faked command matched %s', fake_replier[0]) break if isinstance(reply_handler, six.string_types): @@ -92,11 +91,11 @@ def fake_execute(*cmd_parts, **kwargs): run_as_root=run_as_root, check_exit_code=check_exit_code) except processutils.ProcessExecutionError as e: - LOG.debug(_('Faked command raised an exception %s'), e) + LOG.debug('Faked command raised an exception %s', e) raise - LOG.debug(_("Reply to faked command is stdout='%(stdout)s' " - "stderr='%(stderr)s'") % {'stdout': reply[0], 'stderr': reply[1]}) + LOG.debug("Reply to faked command is stdout='%(stdout)s' " + "stderr='%(stderr)s'", {'stdout': reply[0], 'stderr': reply[1]}) # Replicate the sleep call in the real function greenthread.sleep(0) diff --git a/nova/tests/integrated/api/client.py b/nova/tests/integrated/api/client.py index c9cd439296..da80e5bd3b 100644 --- a/nova/tests/integrated/api/client.py +++ b/nova/tests/integrated/api/client.py @@ -126,7 +126,7 @@ class TestOpenStackClient(object): headers=headers) http_status = response.status - LOG.debug(_("%(auth_uri)s => code %(http_status)s") % + LOG.debug("%(auth_uri)s => code %(http_status)s", {'auth_uri': auth_uri, 'http_status': http_status}) if http_status == 401: @@ -157,7 +157,7 @@ class TestOpenStackClient(object): response = self.request(full_uri, **kwargs) http_status = response.status - LOG.debug(_("%(relative_uri)s => code %(http_status)s") % + LOG.debug("%(relative_uri)s => code %(http_status)s", {'relative_uri': relative_uri, 'http_status': http_status}) if check_response_status: @@ -175,7 +175,7 @@ class TestOpenStackClient(object): def _decode_json(self, response): body = response.read() - LOG.debug(_("Decoding JSON: %s") % (body)) + LOG.debug("Decoding JSON: %s", body) if body: return jsonutils.loads(body) else: diff --git a/nova/tests/integrated/test_login.py b/nova/tests/integrated/test_login.py index b0d2880ec8..4fd22ea060 100644 --- a/nova/tests/integrated/test_login.py +++ b/nova/tests/integrated/test_login.py @@ -14,7 +14,6 @@ # under the License. -from nova.openstack.common.gettextutils import _ from nova.openstack.common import log as logging from nova.tests.integrated.api import client from nova.tests.integrated import integrated_helpers @@ -30,7 +29,7 @@ class LoginTest(integrated_helpers._IntegratedTestBase): # Simple check - we list flavors - so we know we're logged in. flavors = self.api.get_flavors() for flavor in flavors: - LOG.debug(_("flavor: %s") % flavor) + LOG.debug("flavor: %s", flavor) class LoginTestV3(client.TestOpenStackClientV3Mixin, LoginTest): diff --git a/nova/tests/virt/xenapi/test_xenapi.py b/nova/tests/virt/xenapi/test_xenapi.py index 3f37fa6050..6395d11708 100644 --- a/nova/tests/virt/xenapi/test_xenapi.py +++ b/nova/tests/virt/xenapi/test_xenapi.py @@ -40,7 +40,6 @@ from nova import db from nova import exception from nova.objects import aggregate as aggregate_obj from nova.objects import instance as instance_obj -from nova.openstack.common.gettextutils import _ from nova.openstack.common import importutils from nova.openstack.common import jsonutils from nova.openstack.common import log as logging @@ -948,7 +947,7 @@ class XenAPIVMTestCase(stubs.XenAPITestBase): # mount point will be the last item of the command list self._tmpdir = cmd[len(cmd) - 1] - LOG.debug(_('Creating files in %s to simulate guest agent'), + LOG.debug('Creating files in %s to simulate guest agent', self._tmpdir) os.makedirs(os.path.join(self._tmpdir, 'usr', 'sbin')) # Touch the file using open @@ -959,7 +958,7 @@ class XenAPIVMTestCase(stubs.XenAPITestBase): def _umount_handler(cmd, *ignore_args, **ignore_kwargs): # Umount would normall make files in the m,ounted filesystem # disappear, so do that here - LOG.debug(_('Removing simulated guest agent files in %s'), + LOG.debug('Removing simulated guest agent files in %s', self._tmpdir) os.remove(os.path.join(self._tmpdir, 'usr', 'sbin', 'xe-update-networking'))