Log task ID when the task status changes

This patch adds the task ID to the existing log messages which
occur when the task status changes, whether successful or a
failure.

Change-Id: Ie1ebdd92805370b706d8d9eec29d1b433095369a
Closes-Bug: 1358888
This commit is contained in:
eddie-sheffield 2014-08-19 01:16:57 -04:00
parent 01ced52576
commit d8d15d39fa
1 changed files with 8 additions and 6 deletions

View File

@ -366,14 +366,16 @@ class Task(object):
def _set_task_status(self, new_status):
if self._validate_task_status_transition(self.status, new_status):
self._status = new_status
log_msg = (_("Task status changed from %(cur_status)s to "
"%(new_status)s") % {'cur_status': self.status,
'new_status': new_status})
log_msg = (_("Task [%(task_id)s] status changing from "
"%(cur_status)s to %(new_status)s") %
{'task_id': self.task_id, 'cur_status': self.status,
'new_status': new_status})
LOG.info(log_msg)
else:
log_msg = (_("Task status failed to change from %(cur_status)s "
"to %(new_status)s") % {'cur_status': self.status,
'new_status': new_status})
log_msg = (_("Task [%(task_id)s] status failed to change from "
"%(cur_status)s to %(new_status)s") %
{'task_id': self.task_id, 'cur_status': self.status,
'new_status': new_status})
LOG.error(log_msg)
raise exception.InvalidTaskStatusTransition(
cur_status=self.status,