Don't translate debug level logs in nova

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).

This is the final patch ensuring that all fines in the nova directory
no longer have translations for debug messages.

Change-Id: Ib10f5826e2238cbb2d4315c48be570eb31b2ea55
This commit is contained in:
Gary Kotton
2014-06-12 01:40:36 -07:00
parent f766da15ab
commit 4dcf093236
10 changed files with 20 additions and 50 deletions

View File

@@ -527,5 +527,5 @@ def volume_in_mapping(mount_device, block_device_info):
driver.block_device_info_get_ephemerals(
block_device_info)]
LOG.debug(_("block_device_list %s"), block_device_list)
LOG.debug("block_device_list %s", block_device_list)
return strip_dev(mount_device) in block_device_list

View File

@@ -390,7 +390,7 @@ def _sign_csr(csr_text, ca_folder):
with excutils.save_and_reraise_exception():
LOG.exception(_('Failed to write inbound.csr'))
LOG.debug(_('Flags path: %s'), ca_folder)
LOG.debug('Flags path: %s', ca_folder)
start = os.getcwd()
# Change working dir to CA

View File

@@ -64,7 +64,7 @@ def init():
from nova.openstack.common import log as logging
LOG = logging.getLogger(__name__)
LOG.debug(_('Listening on %(host)s:%(port)s for debug connection'),
LOG.debug('Listening on %(host)s:%(port)s for debug connection',
{'host': CONF.remote_debug.host,
'port': CONF.remote_debug.port})

View File

@@ -67,7 +67,7 @@ class BaseFilterHandler(loadables.BaseLoader):
def get_filtered_objects(self, filter_classes, objs,
filter_properties, index=0):
list_objs = list(objs)
LOG.debug(_("Starting with %d host(s)"), len(list_objs))
LOG.debug("Starting with %d host(s)", len(list_objs))
for filter_cls in filter_classes:
cls_name = filter_cls.__name__
filter = filter_cls()
@@ -76,14 +76,14 @@ class BaseFilterHandler(loadables.BaseLoader):
objs = filter.filter_all(list_objs,
filter_properties)
if objs is None:
LOG.debug(_("Filter %(cls_name)s says to stop filtering"),
{'cls_name': cls_name})
LOG.debug("Filter %(cls_name)s says to stop filtering",
{'cls_name': cls_name})
return
list_objs = list(objs)
if not list_objs:
LOG.info(_("Filter %s returned 0 hosts"), cls_name)
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)})
return list_objs

View File

@@ -216,37 +216,8 @@ def no_translate_debug_logs(logical_line, filename):
N319
"""
dirs = ["nova/scheduler",
"nova/network",
"nova/volume",
"nova/api",
"nova/cells",
"nova/conductor",
"nova/compute",
"nova/objects",
"nova/cmd",
"nova/db",
"nova/cert",
"nova/console",
"nova/consoleauth",
"nova/cloudpipe",
"nova/image",
"nova/hacking",
"nova/ipv6",
"nova/keymgr",
"nova/objectstore",
"nova/pci",
"nova/rdp",
"nova/servicegroup",
"nova/spice",
"nova/storage",
"nova/tests",
"nova/vnc",
"nova/virt",
]
if max([name in filename for name in dirs]):
if logical_line.startswith("LOG.debug(_("):
yield(0, "N319 Don't translate debug level logs")
if logical_line.startswith("LOG.debug(_("):
yield(0, "N319 Don't translate debug level logs")
def no_setting_conf_directly_in_tests(logical_line, filename):

View File

@@ -46,7 +46,6 @@ import functools
import stevedore
from nova.openstack.common.gettextutils import _
from nova.openstack.common import log as logging
LOG = logging.getLogger(__name__)
@@ -65,7 +64,7 @@ class HookManager(stevedore.hook.HookManager):
obj = e.obj
pre = getattr(obj, 'pre', None)
if pre:
LOG.debug(_("Running %(name)s pre-hook: %(obj)s"),
LOG.debug("Running %(name)s pre-hook: %(obj)s",
{'name': name, 'obj': obj})
if f:
pre(f, *args, **kwargs)
@@ -77,7 +76,7 @@ class HookManager(stevedore.hook.HookManager):
obj = e.obj
post = getattr(obj, 'post', None)
if post:
LOG.debug(_("Running %(name)s post-hook: %(obj)s"),
LOG.debug("Running %(name)s post-hook: %(obj)s",
{'name': name, 'obj': obj})
if f:
post(f, rv, *args, **kwargs)

View File

@@ -1300,7 +1300,7 @@ class QuotaEngine(object):
project_id=project_id,
user_id=user_id)
LOG.debug(_("Created reservations %s"), reservations)
LOG.debug("Created reservations %s", reservations)
return reservations
@@ -1325,7 +1325,7 @@ class QuotaEngine(object):
# logged, however, because this is less than optimal.
LOG.exception(_("Failed to commit reservations %s"), reservations)
return
LOG.debug(_("Committed reservations %s"), reservations)
LOG.debug("Committed reservations %s", reservations)
def rollback(self, context, reservations, project_id=None, user_id=None):
"""Roll back reservations.
@@ -1349,7 +1349,7 @@ class QuotaEngine(object):
LOG.exception(_("Failed to roll back reservations %s"),
reservations)
return
LOG.debug(_("Rolled back reservations %s"), reservations)
LOG.debug("Rolled back reservations %s", reservations)
def usage_reset(self, context, resources):
"""Reset the usage records for a particular user on a list of

View File

@@ -181,7 +181,7 @@ class Service(service.Service):
if self.backdoor_port is not None:
self.manager.backdoor_port = self.backdoor_port
LOG.debug(_("Creating RPC server for service %s") % self.topic)
LOG.debug("Creating RPC server for service %s", self.topic)
target = messaging.Target(topic=self.topic, server=self.host)
@@ -198,8 +198,8 @@ class Service(service.Service):
self.manager.post_start_hook()
LOG.debug(_("Join ServiceGroup membership for this service %s")
% self.topic)
LOG.debug("Join ServiceGroup membership for this service %s",
self.topic)
# Add service to the ServiceGroup membership group.
self.servicegroup_api.join(self.host, self.topic, self)

View File

@@ -659,7 +659,7 @@ def read_cached_file(filename, cache_info, reload_func=None):
"""
mtime = os.path.getmtime(filename)
if not cache_info or mtime != cache_info.get('mtime'):
LOG.debug(_("Reloading cached file %s") % filename)
LOG.debug("Reloading cached file %s", filename)
with open(filename) as fap:
cache_info['data'] = fap.read()
cache_info['mtime'] = mtime

View File

@@ -497,7 +497,7 @@ class Loader(object):
"""
try:
LOG.debug(_("Loading app %(name)s from %(path)s") %
LOG.debug("Loading app %(name)s from %(path)s",
{'name': name, 'path': self.config_path})
return deploy.loadapp("config:%s" % self.config_path, name=name)
except LookupError as err: