Cut too long task result in log
* Added function 'cut()' for cut data to specific length * Apply this function to WF_TRACE logging in result output. Change-Id: Iffca824c8568897790e5a7054031b1a0292e0e45
This commit is contained in:
parent
70f46b0aa5
commit
2435f34afa
@ -134,3 +134,15 @@ def get_file_list(directory):
|
||||
|
||||
return [path.join(base_path, f) for f in os.listdir(base_path)
|
||||
if path.isfile(path.join(base_path, f))]
|
||||
|
||||
|
||||
def cut(data, length=100):
|
||||
if not data:
|
||||
return data
|
||||
|
||||
string = str(data)
|
||||
|
||||
if len(string) > length:
|
||||
return "%s..." % string[:length]
|
||||
else:
|
||||
return string
|
||||
|
@ -18,6 +18,7 @@ from oslo.config import cfg
|
||||
|
||||
from mistral import exceptions as exc
|
||||
from mistral.openstack.common import log as logging
|
||||
from mistral import utils
|
||||
from mistral.workbook import parser as spec_parser
|
||||
from mistral.workflow import data_flow
|
||||
from mistral.workflow import states
|
||||
@ -78,9 +79,12 @@ class WorkflowHandler(object):
|
||||
|
||||
wf_trace_msg += "%s" % task_db.state
|
||||
if task_db.state == states.ERROR:
|
||||
WF_TRACE.info(wf_trace_msg + ", error = %s]" % raw_result.error)
|
||||
wf_trace_msg += ", error = %s]" % utils.cut(raw_result.error)
|
||||
WF_TRACE.info(wf_trace_msg)
|
||||
else:
|
||||
WF_TRACE.info(wf_trace_msg + ", result = %s]" % raw_result.data)
|
||||
wf_trace_msg += ", result = %s]" % utils.cut(raw_result.data)
|
||||
|
||||
WF_TRACE.info(wf_trace_msg)
|
||||
|
||||
task_db.output =\
|
||||
data_flow.evaluate_task_output(task_spec, raw_result)
|
||||
|
Loading…
Reference in New Issue
Block a user