Don't translate debug level logs in nova.cert, console and consoleauth

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: I9a0c718fc71e456baf87d1d28827654a015c62a6
This commit is contained in:
Gary Kotton 2014-04-29 03:31:03 -07:00 committed by garyk
parent fc66b094db
commit 0c25fbbac8
4 changed files with 18 additions and 17 deletions

View File

@ -23,7 +23,6 @@ from oslo import messaging
from nova.compute import rpcapi as compute_rpcapi
from nova import exception
from nova import manager
from nova.openstack.common.gettextutils import _
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
from nova import utils
@ -77,7 +76,7 @@ class ConsoleProxyManager(manager.Manager):
pool['id'],
instance['uuid'])
except exception.NotFound:
LOG.debug(_('Adding console'), instance=instance)
LOG.debug('Adding console', instance=instance)
password = utils.generate_password(8)
port = self.driver.get_port(context)
console_data = {'instance_name': name,
@ -95,9 +94,9 @@ class ConsoleProxyManager(manager.Manager):
try:
console = self.db.console_get(context, console_id)
except exception.NotFound:
LOG.debug(_('Tried to remove non-existent console '
'%(console_id)s.') %
{'console_id': console_id})
LOG.debug('Tried to remove non-existent console '
'%(console_id)s.',
{'console_id': console_id})
return
self.db.console_delete(context, console_id)
self.driver.teardown_console(context, console)

View File

@ -20,7 +20,6 @@ from oslo.config import cfg
from nova.compute import rpcapi as compute_rpcapi
from nova import exception
from nova import manager
from nova.openstack.common.gettextutils import _
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
from nova.virt.vmwareapi import driver as vmwareapi_conn
@ -59,7 +58,7 @@ class ConsoleVMRCManager(manager.Manager):
def _generate_console(self, context, pool, name, instance_id, instance):
"""Sets up console for the instance."""
LOG.debug(_('Adding console'))
LOG.debug('Adding console')
password = self.driver.generate_password(
self._get_vim_session(pool),
@ -109,11 +108,11 @@ class ConsoleVMRCManager(manager.Manager):
try:
console = self.db.console_get(context, console_id)
except exception.NotFound:
LOG.debug(_('Tried to remove non-existent console '
'%(console_id)s.') % {'console_id': console_id})
LOG.debug('Tried to remove non-existent console '
'%(console_id)s.', {'console_id': console_id})
return
LOG.debug(_('Removing console '
'%(console_id)s.') % {'console_id': console_id})
LOG.debug('Removing console '
'%(console_id)s.', {'console_id': console_id})
self.db.console_delete(context, console_id)
self.driver.teardown_console(context, console)

View File

@ -96,7 +96,7 @@ class XVPConsoleProxy(object):
return self._xvp_encrypt(password)
def _rebuild_xvp_conf(self, context):
LOG.debug(_('Rebuilding xvp conf'))
LOG.debug('Rebuilding xvp conf')
pools = [pool for pool in
db.console_pool_get_all_by_host_type(context, self.host,
self.console_type)
@ -116,7 +116,7 @@ class XVPConsoleProxy(object):
def _write_conf(self, config):
try:
LOG.debug(_('Re-wrote %s') % CONF.console_xvp_conf)
LOG.debug('Re-wrote %s', CONF.console_xvp_conf)
with open(CONF.console_xvp_conf, 'w') as cfile:
cfile.write(config)
except IOError:
@ -124,7 +124,7 @@ class XVPConsoleProxy(object):
LOG.exception(_("Failed to write configuration file"))
def _xvp_stop(self):
LOG.debug(_('Stopping xvp'))
LOG.debug('Stopping xvp')
pid = self._xvp_pid()
if not pid:
return
@ -137,7 +137,7 @@ class XVPConsoleProxy(object):
def _xvp_start(self):
if self._xvp_check_running():
return
LOG.debug(_('Starting xvp'))
LOG.debug('Starting xvp')
try:
utils.execute('xvp',
'-p', CONF.console_xvp_pid,
@ -147,9 +147,9 @@ class XVPConsoleProxy(object):
LOG.error(_('Error starting xvp: %s') % err)
def _xvp_restart(self):
LOG.debug(_('Restarting xvp'))
LOG.debug('Restarting xvp')
if not self._xvp_check_running():
LOG.debug(_('xvp not running...'))
LOG.debug('xvp not running...')
self._xvp_start()
else:
pid = self._xvp_pid()

View File

@ -216,6 +216,9 @@ def no_translate_debug_logs(logical_line, filename):
"nova/objects",
"nova/cmd",
"nova/db",
"nova/cert",
"nova/console",
"nova/consoleauth",
]
if max([name in filename for name in dirs]):
if logical_line.startswith("LOG.debug(_("):