Use the right log marker functions
According to [1] _LI() should be used for LOG.info(), _LE() for LOG.exception() and LOG.error(), _LW() for LOG.warning(). The log marker functions must only be used when the message is sent directly to the log. Debug level log messages should not be translated. [1] http://docs.openstack.org/developer/oslo.i18n/guidelines.html Change-Id: Ib9f92ef6696b9a95ddae74f0d4a0a557c06ecc91
This commit is contained in:
parent
dcd27c89d6
commit
4801c0f894
@ -35,7 +35,7 @@ from oslo.config import cfg
|
||||
from oslo import i18n
|
||||
|
||||
from heat.common import config
|
||||
from heat.common.i18n import _
|
||||
from heat.common.i18n import _LI
|
||||
from heat.common import messaging
|
||||
from heat.common import profiler
|
||||
from heat.common import wsgi
|
||||
@ -56,7 +56,7 @@ if __name__ == '__main__':
|
||||
|
||||
port = cfg.CONF.heat_api.bind_port
|
||||
host = cfg.CONF.heat_api.bind_host
|
||||
LOG.info(_('Starting Heat ReST API on %(host)s:%(port)s'),
|
||||
LOG.info(_LI('Starting Heat ReST API on %(host)s:%(port)s'),
|
||||
{'host': host, 'port': port})
|
||||
profiler.setup('heat-api', host)
|
||||
server = wsgi.Server()
|
||||
|
@ -37,7 +37,7 @@ from oslo.config import cfg
|
||||
from oslo import i18n
|
||||
|
||||
from heat.common import config
|
||||
from heat.common.i18n import _
|
||||
from heat.common.i18n import _LI
|
||||
from heat.common import messaging
|
||||
from heat.common import profiler
|
||||
from heat.common import wsgi
|
||||
@ -58,7 +58,7 @@ if __name__ == '__main__':
|
||||
|
||||
port = cfg.CONF.heat_api_cfn.bind_port
|
||||
host = cfg.CONF.heat_api_cfn.bind_host
|
||||
LOG.info(_('Starting Heat API on %(host)s:%(port)s'),
|
||||
LOG.info(_LI('Starting Heat API on %(host)s:%(port)s'),
|
||||
{'host': host, 'port': port})
|
||||
profiler.setup('heat-api-cfn', host)
|
||||
server = wsgi.Server()
|
||||
|
@ -37,7 +37,7 @@ from oslo.config import cfg
|
||||
from oslo import i18n
|
||||
|
||||
from heat.common import config
|
||||
from heat.common.i18n import _
|
||||
from heat.common.i18n import _LI
|
||||
from heat.common import messaging
|
||||
from heat.common import profiler
|
||||
from heat.common import wsgi
|
||||
@ -58,7 +58,7 @@ if __name__ == '__main__':
|
||||
|
||||
port = cfg.CONF.heat_api_cloudwatch.bind_port
|
||||
host = cfg.CONF.heat_api_cloudwatch.bind_host
|
||||
LOG.info(_('Starting Heat CloudWatch API on %(host)s:%(port)s'),
|
||||
LOG.info(_LI('Starting Heat CloudWatch API on %(host)s:%(port)s'),
|
||||
{'host': host, 'port': port})
|
||||
profiler.setup('heat-api-cloudwatch', host)
|
||||
server = wsgi.Server()
|
||||
|
@ -21,6 +21,9 @@ import pkg_resources
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from heat.common.i18n import _LE
|
||||
from heat.common.i18n import _LI
|
||||
|
||||
|
||||
VAR_PATH = '/var/lib/heat-cfntools'
|
||||
LOG = logging.getLogger('heat-provision')
|
||||
@ -59,14 +62,14 @@ def call(args):
|
||||
except OSError:
|
||||
ex_type, ex, tb = sys.exc_info()
|
||||
if ex.errno == errno.ENOEXEC:
|
||||
LOG.error('Userdata empty or not executable: %s', ex)
|
||||
LOG.error(_LE('Userdata empty or not executable: %s'), ex)
|
||||
return os.EX_OK
|
||||
else:
|
||||
LOG.error('OS error running userdata: %s', ex)
|
||||
LOG.error(_LE('OS error running userdata: %s'), ex)
|
||||
return os.EX_OSERR
|
||||
except Exception:
|
||||
ex_type, ex, tb = sys.exc_info()
|
||||
LOG.error('Unknown error running userdata: %s', ex)
|
||||
LOG.error(_LE('Unknown error running userdata: %s'), ex)
|
||||
return os.EX_SOFTWARE
|
||||
return p.returncode
|
||||
|
||||
@ -75,16 +78,16 @@ def main():
|
||||
|
||||
if not chk_ci_version():
|
||||
# pre 0.6.0 - user data executed via cloudinit, not this helper
|
||||
LOG.error('Unable to log provisioning, need a newer version of'
|
||||
' cloud-init')
|
||||
LOG.error(_LE('Unable to log provisioning, need a newer version '
|
||||
'of cloud-init'))
|
||||
return -1
|
||||
|
||||
userdata_path = os.path.join(VAR_PATH, 'cfn-userdata')
|
||||
os.chmod(userdata_path, int("700", 8))
|
||||
|
||||
LOG.info('Provision began: %s', datetime.datetime.now())
|
||||
LOG.info(_LI('Provision began: %s'), datetime.datetime.now())
|
||||
returncode = call([userdata_path])
|
||||
LOG.info('Provision done: %s', datetime.datetime.now())
|
||||
LOG.info(_LI('Provision done: %s'), datetime.datetime.now())
|
||||
if returncode:
|
||||
return returncode
|
||||
|
||||
@ -94,7 +97,7 @@ if __name__ == '__main__':
|
||||
|
||||
code = main()
|
||||
if code:
|
||||
LOG.error('Provision failed with exit code %s', code)
|
||||
LOG.error(_LE('Provision failed with exit code %s'), code)
|
||||
sys.exit(code)
|
||||
|
||||
provision_log = os.path.join(VAR_PATH, 'provision-finished')
|
||||
|
@ -23,6 +23,7 @@ import six
|
||||
from six.moves.urllib import parse as urlparse
|
||||
|
||||
from heat.common.i18n import _
|
||||
from heat.common.i18n import _LE
|
||||
from heat.openstack.common import log as logging
|
||||
|
||||
|
||||
@ -112,7 +113,7 @@ class HeatException(Exception):
|
||||
exc_info = sys.exc_info()
|
||||
#kwargs doesn't match a variable in the message
|
||||
#log the issue and the kwargs
|
||||
LOG.exception(_('Exception in string format operation'))
|
||||
LOG.exception(_LE('Exception in string format operation'))
|
||||
for name, value in six.iteritems(kwargs):
|
||||
LOG.error("%s: %s" % (name, value)) # noqa
|
||||
|
||||
|
@ -320,11 +320,11 @@ class KeystoneClientV3(object):
|
||||
if len(domains) == 1:
|
||||
return domains[0].id
|
||||
elif len(domains) == 0:
|
||||
msg = _LE('Can\'t find domain id for %s!')
|
||||
msg = _('Can\'t find domain id for %s!')
|
||||
LOG.error(msg, domain_name)
|
||||
raise exception.Error(msg % domain_name)
|
||||
else:
|
||||
msg = _LE('Multiple domain ids were found for %s!')
|
||||
msg = _('Multiple domain ids were found for %s!')
|
||||
LOG.error(msg, domain_name)
|
||||
raise exception.Error(msg % domain_name)
|
||||
|
||||
@ -524,12 +524,12 @@ class KeystoneClientV3(object):
|
||||
try:
|
||||
project = self.domain_admin_client.projects.get(project=project_id)
|
||||
except kc_exception.Forbidden:
|
||||
LOG.warning(_('Unable to get details for project %s, not deleting')
|
||||
% project_id)
|
||||
LOG.warning(_LW('Unable to get details for project %s, '
|
||||
'not deleting') % project_id)
|
||||
return
|
||||
|
||||
if project.domain_id != self.stack_domain_id:
|
||||
LOG.warning(_('Not deleting non heat-domain project'))
|
||||
LOG.warning(_LW('Not deleting non heat-domain project'))
|
||||
return
|
||||
|
||||
try:
|
||||
|
@ -15,8 +15,8 @@
|
||||
'''
|
||||
Utility for fetching and running plug point implementation classes
|
||||
'''
|
||||
from heat.common.i18n import _
|
||||
from heat.common.i18n import _LE
|
||||
from heat.common.i18n import _LI
|
||||
from heat.engine import resources
|
||||
from heat.openstack.common import log as logging
|
||||
|
||||
@ -113,6 +113,6 @@ def _do_ops(cinstances, opname, cnxt, stack, current_stack=None, action=None,
|
||||
failure = True
|
||||
failure_exception_message = ex.args[0] if ex.args else str(ex)
|
||||
break
|
||||
LOG.info(_("done with class=%(c)s, stackid=%(sid)s, action=%(a)s") %
|
||||
LOG.info(_LI("done with class=%(c)s, stackid=%(sid)s, action=%(a)s") %
|
||||
{'c': type(ci), 'sid': stack.id, 'a': action})
|
||||
return (failure, failure_exception_message, success_count)
|
||||
|
@ -17,6 +17,7 @@ import osprofiler.profiler
|
||||
import osprofiler.web
|
||||
|
||||
from heat.common import context
|
||||
from heat.common.i18n import _LW
|
||||
from heat.common import messaging as rpc_messaging
|
||||
from heat.openstack.common import log as logging
|
||||
|
||||
@ -31,14 +32,14 @@ def setup(binary, host):
|
||||
"Messaging", messaging, context.get_admin_context().to_dict(),
|
||||
rpc_messaging.TRANSPORT, "heat", binary, host)
|
||||
osprofiler.notifier.set(_notifier)
|
||||
LOG.warning("OSProfiler is enabled.\nIt means that person who knows "
|
||||
"any of hmac_keys that are specified in "
|
||||
"/etc/heat/api-paste.ini can trace his requests. \n"
|
||||
"In real life only operator can read this file so there "
|
||||
"is no security issue. Note that even if person can "
|
||||
"trigger profiler, only admin user can retrieve trace "
|
||||
"information.\n"
|
||||
"To disable OSprofiler set in heat.conf:\n"
|
||||
"[profiler]\nenabled=false")
|
||||
LOG.warning(_LW("OSProfiler is enabled.\nIt means that person who "
|
||||
"knows any of hmac_keys that are specified in "
|
||||
"/etc/heat/api-paste.ini can trace his requests. \n"
|
||||
"In real life only operator can read this file so "
|
||||
"there is no security issue. Note that even if person "
|
||||
"can trigger profiler, only admin user can retrieve "
|
||||
"trace information.\n"
|
||||
"To disable OSprofiler set in heat.conf:\n"
|
||||
"[profiler]\nenabled=false"))
|
||||
else:
|
||||
osprofiler.web.disable()
|
||||
|
@ -46,6 +46,9 @@ import webob.exc
|
||||
from heat.api.aws import exception as aws_exception
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
from heat.common.i18n import _LE
|
||||
from heat.common.i18n import _LI
|
||||
from heat.common.i18n import _LW
|
||||
from heat.common import serializers
|
||||
|
||||
|
||||
@ -260,7 +263,7 @@ class Server(object):
|
||||
"""
|
||||
def kill_children(*args):
|
||||
"""Kills the entire process group."""
|
||||
self.LOG.error(_('SIGTERM received'))
|
||||
self.LOG.error(_LE('SIGTERM received'))
|
||||
signal.signal(signal.SIGTERM, signal.SIG_IGN)
|
||||
self.running = False
|
||||
os.killpg(0, signal.SIGTERM)
|
||||
@ -269,7 +272,7 @@ class Server(object):
|
||||
"""
|
||||
Shuts down the server(s), but allows running requests to complete
|
||||
"""
|
||||
self.LOG.error(_('SIGHUP received'))
|
||||
self.LOG.error(_LE('SIGHUP received'))
|
||||
signal.signal(signal.SIGHUP, signal.SIG_IGN)
|
||||
os.killpg(0, signal.SIGHUP)
|
||||
signal.signal(signal.SIGHUP, hup)
|
||||
@ -286,7 +289,7 @@ class Server(object):
|
||||
self.pool.spawn_n(self._single_run, application, self.sock)
|
||||
return
|
||||
|
||||
self.LOG.info(_("Starting %d workers") % conf.workers)
|
||||
self.LOG.info(_LI("Starting %d workers") % conf.workers)
|
||||
signal.signal(signal.SIGTERM, kill_children)
|
||||
signal.signal(signal.SIGHUP, hup)
|
||||
while len(self.children) < conf.workers:
|
||||
@ -297,14 +300,14 @@ class Server(object):
|
||||
try:
|
||||
pid, status = os.wait()
|
||||
if os.WIFEXITED(status) or os.WIFSIGNALED(status):
|
||||
self.LOG.error(_('Removing dead child %s') % pid)
|
||||
self.LOG.error(_LE('Removing dead child %s') % pid)
|
||||
self.children.remove(pid)
|
||||
self.run_child()
|
||||
except OSError as err:
|
||||
if err.errno not in (errno.EINTR, errno.ECHILD):
|
||||
raise
|
||||
except KeyboardInterrupt:
|
||||
self.LOG.info(_('Caught keyboard interrupt. Exiting.'))
|
||||
self.LOG.info(_LI('Caught keyboard interrupt. Exiting.'))
|
||||
os.killpg(0, signal.SIGTERM)
|
||||
break
|
||||
eventlet.greenio.shutdown_safe(self.sock)
|
||||
@ -327,10 +330,10 @@ class Server(object):
|
||||
signal.signal(signal.SIGHUP, signal.SIG_DFL)
|
||||
signal.signal(signal.SIGTERM, signal.SIG_DFL)
|
||||
self.run_server()
|
||||
self.LOG.info(_('Child %d exiting normally') % os.getpid())
|
||||
self.LOG.info(_LI('Child %d exiting normally') % os.getpid())
|
||||
return
|
||||
else:
|
||||
self.LOG.info(_('Started child %s') % pid)
|
||||
self.LOG.info(_LI('Started child %s') % pid)
|
||||
self.children.append(pid)
|
||||
|
||||
def run_server(self):
|
||||
@ -353,7 +356,7 @@ class Server(object):
|
||||
|
||||
def _single_run(self, application, sock):
|
||||
"""Start a WSGI server in a new green thread."""
|
||||
self.LOG.info(_("Starting single process server"))
|
||||
self.LOG.info(_LI("Starting single process server"))
|
||||
eventlet.wsgi.server(sock, application,
|
||||
custom_pool=self.pool,
|
||||
url_length_limit=URL_LENGTH_LIMIT,
|
||||
@ -627,13 +630,13 @@ class Resource(object):
|
||||
action_args.update(deserialized_request)
|
||||
|
||||
logging.debug(
|
||||
_('Calling %(controller)s : %(action)s'),
|
||||
('Calling %(controller)s : %(action)s'),
|
||||
{'controller': self.controller, 'action': action})
|
||||
|
||||
action_result = self.dispatch(self.controller, action,
|
||||
request, **action_args)
|
||||
except TypeError as err:
|
||||
logging.error(_('Exception handling resource: %s') % err)
|
||||
logging.error(_LE('Exception handling resource: %s') % err)
|
||||
msg = _('The server could not comply with the request since '
|
||||
'it is either malformed or otherwise incorrect.')
|
||||
err = webob.exc.HTTPBadRequest(msg)
|
||||
@ -655,7 +658,7 @@ class Resource(object):
|
||||
raise
|
||||
if isinstance(err, webob.exc.HTTPServerError):
|
||||
logging.error(
|
||||
_("Returning %(code)s to user: %(explanation)s"),
|
||||
_LE("Returning %(code)s to user: %(explanation)s"),
|
||||
{'code': err.code, 'explanation': err.explanation})
|
||||
http_exc = translate_exception(err, request.best_match_language())
|
||||
raise exception.HTTPExceptionDisguise(http_exc)
|
||||
@ -694,7 +697,7 @@ class Resource(object):
|
||||
err_body = action_result.get_unserialized_body()
|
||||
serializer.default(action_result, err_body)
|
||||
except Exception:
|
||||
logging.warning(_("Unable to serialize exception "
|
||||
logging.warning(_LW("Unable to serialize exception "
|
||||
"response"))
|
||||
|
||||
return action_result
|
||||
@ -729,7 +732,7 @@ class Resource(object):
|
||||
|
||||
def log_exception(err, exc_info):
|
||||
args = {'exc_info': exc_info} if cfg.CONF.verbose or cfg.CONF.debug else {}
|
||||
logging.error(_("Unexpected error occurred serving API: %s") % err,
|
||||
logging.error(_LE("Unexpected error occurred serving API: %s") % err,
|
||||
**args)
|
||||
|
||||
|
||||
|
@ -36,7 +36,7 @@ def extract_args(params):
|
||||
try:
|
||||
timeout = int(timeout_mins)
|
||||
except (ValueError, TypeError):
|
||||
LOG.exception(_('Timeout conversion failed'))
|
||||
LOG.exception(_LE('Timeout conversion failed'))
|
||||
else:
|
||||
if timeout > 0:
|
||||
kwargs[api.PARAM_TIMEOUT] = timeout
|
||||
|
@ -475,7 +475,7 @@ class Resource(object):
|
||||
try:
|
||||
self.state_set(action, self.FAILED, '%s aborted' % action)
|
||||
except Exception:
|
||||
LOG.exception(_('Error marking resource as failed'))
|
||||
LOG.exception(_LE('Error marking resource as failed'))
|
||||
else:
|
||||
self.state_set(action, self.COMPLETE)
|
||||
|
||||
@ -1079,7 +1079,7 @@ class Resource(object):
|
||||
reason_string = get_string_details()
|
||||
self._add_event('signal', self.status, reason_string)
|
||||
except Exception as ex:
|
||||
LOG.exception(_('signal %(name)s : %(msg)s')
|
||||
LOG.exception(_LE('signal %(name)s : %(msg)s')
|
||||
% {'name': six.text_type(self), 'msg': ex})
|
||||
failure = exception.ResourceFailure(ex, self)
|
||||
raise failure
|
||||
|
@ -17,6 +17,7 @@ import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
from heat.common.i18n import _LE
|
||||
from heat.common.i18n import _LI
|
||||
from heat.engine import constraints
|
||||
from heat.engine.notification import autoscaling as notification
|
||||
@ -56,11 +57,11 @@ def _calculate_new_capacity(current, adjustment, adjustment_type,
|
||||
new_capacity = current + rounded
|
||||
|
||||
if new_capacity > maximum:
|
||||
LOG.debug(_('truncating growth to %s') % maximum)
|
||||
LOG.debug('truncating growth to %s' % maximum)
|
||||
return maximum
|
||||
|
||||
if new_capacity < minimum:
|
||||
LOG.debug(_('truncating shrinkage to %s') % minimum)
|
||||
LOG.debug('truncating shrinkage to %s' % minimum)
|
||||
return minimum
|
||||
|
||||
return new_capacity
|
||||
@ -288,7 +289,7 @@ class AutoScalingGroup(instgrp.InstanceGroup, cooldown.CooldownMixin):
|
||||
})
|
||||
notification.send(**notif)
|
||||
except Exception:
|
||||
LOG.exception(_('Failed sending error notification'))
|
||||
LOG.exception(_LE('Failed sending error notification'))
|
||||
else:
|
||||
notif.update({
|
||||
'suffix': 'end',
|
||||
|
@ -1126,8 +1126,8 @@ class Stack(collections.Mapping):
|
||||
res.state_reset()
|
||||
scheduler.TaskRunner(res.create)()
|
||||
except exception.ResourceFailure as ex:
|
||||
LOG.exception(_('Resource %(name)s create failed: %(ex)s')
|
||||
% {'name': res.name, 'ex': ex})
|
||||
LOG.exception(_LE('Resource %(name)s create failed: '
|
||||
'%(ex)s') % {'name': res.name, 'ex': ex})
|
||||
failed = True
|
||||
else:
|
||||
res.state_set(res.CREATE, res.FAILED,
|
||||
|
Loading…
Reference in New Issue
Block a user