Adding Variables to Log Messages

String interpolation should be delayed to be handled by the logging
code,rather than being done at the point of the logging call.
Ref:http://docs.openstack.org/developer/oslo.i18n/guidelines.html#log-translation
For example:
# WRONG
LOG.info(_LI('some message: variable=%s') % variable)
# RIGHT
LOG.info(_LI('some message: variable=%s'), variable)

Change-Id: I86a136c2221d20b2319e7876f1986ba10536853e
This commit is contained in:
zhangyanxian 2016-11-04 07:17:37 +00:00
parent 09b0f87a6a
commit 4e5ca383bc
4 changed files with 15 additions and 15 deletions

View File

@ -54,7 +54,7 @@ class ActionsController(rest.RestController, hooks.HookController):
"""
acl.enforce('actions:get', context.ctx())
LOG.info("Fetch action [identifier=%s]" % identifier)
LOG.info("Fetch action [identifier=%s]", identifier)
db_model = db_api.get_action_definition(identifier)
@ -70,7 +70,7 @@ class ActionsController(rest.RestController, hooks.HookController):
"""
acl.enforce('actions:update', context.ctx())
definition = pecan.request.text
LOG.info("Update action(s) [definition=%s]" % definition)
LOG.info("Update action(s) [definition=%s]", definition)
scope = pecan.request.GET.get('scope', 'private')
if scope not in resources.SCOPE_TYPES.values:
@ -110,7 +110,7 @@ class ActionsController(rest.RestController, hooks.HookController):
"%s" % (resources.SCOPE_TYPES.values, scope)
)
LOG.info("Create action(s) [definition=%s]" % definition)
LOG.info("Create action(s) [definition=%s]", definition)
with db_api.transaction():
db_acts = actions.create_actions(definition, scope=scope)
@ -125,7 +125,7 @@ class ActionsController(rest.RestController, hooks.HookController):
def delete(self, identifier):
"""Delete the named action."""
acl.enforce('actions:delete', context.ctx())
LOG.info("Delete action [identifier=%s]" % identifier)
LOG.info("Delete action [identifier=%s]", identifier)
with db_api.transaction():
db_model = db_api.get_action_definition(identifier)

View File

@ -111,7 +111,7 @@ class ActionExecutionsController(rest.RestController):
"""Return the specified action_execution."""
acl.enforce('action_executions:get', context.ctx())
LOG.info("Fetch action_execution [id=%s]" % id)
LOG.info("Fetch action_execution [id=%s]", id)
return _get_action_execution(id)
@ -122,7 +122,7 @@ class ActionExecutionsController(rest.RestController):
"""Create new action_execution."""
acl.enforce('action_executions:create', context.ctx())
LOG.info("Create action_execution [action_execution=%s]" % action_ex)
LOG.info("Create action_execution [action_execution=%s]", action_ex)
name = action_ex.name
description = action_ex.description or None
@ -268,7 +268,7 @@ class ActionExecutionsController(rest.RestController):
"""Delete the specified action_execution."""
acl.enforce('action_executions:delete', context.ctx())
LOG.info("Delete action_execution [id=%s]" % id)
LOG.info("Delete action_execution [id=%s]", id)
if not cfg.CONF.api.allow_action_execution_deletion:
raise exc.NotAllowedException("Action execution deletion is not "
@ -380,6 +380,6 @@ class TasksActionExecutionController(rest.RestController):
"""Return the specified action_execution."""
acl.enforce('action_executions:get', context.ctx())
LOG.info("Fetch action_execution [id=%s]" % action_ex_id)
LOG.info("Fetch action_execution [id=%s]", action_ex_id)
return _get_action_execution(action_ex_id)

View File

@ -67,7 +67,7 @@ class ExecutionsController(rest.RestController):
"""Return the specified Execution."""
acl.enforce("executions:get", context.ctx())
LOG.info("Fetch execution [id=%s]" % id)
LOG.info("Fetch execution [id=%s]", id)
with db_api.transaction():
wf_ex = db_api.get_workflow_execution(id)
@ -191,7 +191,7 @@ class ExecutionsController(rest.RestController):
"""
acl.enforce('executions:create', context.ctx())
LOG.info('Create execution [execution=%s]' % wf_ex)
LOG.info("Create execution [execution=%s]", wf_ex)
engine = rpc.get_engine_client()
exec_dict = wf_ex.to_dict()
@ -218,7 +218,7 @@ class ExecutionsController(rest.RestController):
"""Delete the specified Execution."""
acl.enforce('executions:delete', context.ctx())
LOG.info('Delete execution [id=%s]' % id)
LOG.info("Delete execution [id=%s]", id)
return db_api.delete_workflow_execution(id)

View File

@ -81,7 +81,7 @@ class WorkflowsController(rest.RestController, hooks.HookController):
"""Return the named workflow."""
acl.enforce('workflows:get', context.ctx())
LOG.info("Fetch workflow [identifier=%s]" % identifier)
LOG.info("Fetch workflow [identifier=%s]", identifier)
db_model = db_api.get_workflow_definition(identifier)
@ -109,7 +109,7 @@ class WorkflowsController(rest.RestController, hooks.HookController):
"%s" % (resources.SCOPE_TYPES.values, scope)
)
LOG.info("Update workflow(s) [definition=%s]" % definition)
LOG.info("Update workflow(s) [definition=%s]", definition)
db_wfs = workflows.update_workflows(
definition,
@ -145,7 +145,7 @@ class WorkflowsController(rest.RestController, hooks.HookController):
"%s" % (resources.SCOPE_TYPES.values, scope)
)
LOG.info("Create workflow(s) [definition=%s]" % definition)
LOG.info("Create workflow(s) [definition=%s]", definition)
db_wfs = workflows.create_workflows(definition, scope=scope)
models_dicts = [db_wf.to_dict() for db_wf in db_wfs]
@ -161,7 +161,7 @@ class WorkflowsController(rest.RestController, hooks.HookController):
def delete(self, identifier):
"""Delete a workflow."""
acl.enforce('workflows:delete', context.ctx())
LOG.info("Delete workflow [identifier=%s]" % identifier)
LOG.info("Delete workflow [identifier=%s]", identifier)
with db_api.transaction():
db_api.delete_workflow_definition(identifier)