Merge "Cut too long task result in log"

This commit is contained in:
Jenkins 2014-10-14 14:20:30 +00:00 committed by Gerrit Code Review
commit 2f6f95b19b
2 changed files with 18 additions and 2 deletions

View File

@ -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

View File

@ -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)