Log items in loops better
If the loop item has a result msg - we should display it. If the loop item doens't have a result msg - there is no other identifying feature than the loop variable - which may be a full dict or other json-object. In that case, pretty print it rather than one-lining it. This may not be perfect - but let's give it a try. Change-Id: Ib9a4dc0ac7783559151f12996144941e534633ee
This commit is contained in:
parent
e60af64c1b
commit
c1229468ad
|
@ -358,9 +358,14 @@ class CallbackModule(default.CallbackModule):
|
|||
status = 'ok'
|
||||
|
||||
if result._task.action not in ('command', 'shell'):
|
||||
if 'msg' in result_dict:
|
||||
self._log_message(
|
||||
result=result, msg=result_dict['msg'], status=status)
|
||||
else:
|
||||
self._log_message(
|
||||
result=result,
|
||||
msg="Item: {item}".format(item=result_dict['item']),
|
||||
msg=json.dumps(result_dict['item'],
|
||||
indent=2, sort_keys=True),
|
||||
status=status)
|
||||
else:
|
||||
self._log_message(
|
||||
|
@ -481,7 +486,8 @@ class CallbackModule(default.CallbackModule):
|
|||
host=hostname,
|
||||
msg="Output suppressed because no_log was given"))
|
||||
return
|
||||
if not msg and set(result_dict.keys()) == set(['msg', 'failed']):
|
||||
if (not msg and result_dict
|
||||
and set(result_dict.keys()) == set(['msg', 'failed'])):
|
||||
msg = result_dict['msg']
|
||||
result_dict = None
|
||||
if msg:
|
||||
|
|
Loading…
Reference in New Issue