aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/core/task.py
diff options
context:
space:
mode:
authorchenjiankun <chenjiankun1@huawei.com>2017-08-09 03:23:58 +0000
committerchenjiankun <chenjiankun1@huawei.com>2017-08-11 09:29:58 +0000
commit43bf12d6ab7bcaea16dc75ed4ccbe3895cf51da3 (patch)
tree234d642e36564dab4e9d48cff09c0b93901c252f /yardstick/benchmark/core/task.py
parent55234666785b0fdc81365da4dac5563e954f8a09 (diff)
Add real time log view in GUI
JIRA: YARDSTICK-775 We have GUI now, but we can't see real time log in GUI view. So I add real time log view in GUI. Change-Id: Ie83f327ef0a94302afa6b3def764fec6ef5818d1 Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'yardstick/benchmark/core/task.py')
-rw-r--r--yardstick/benchmark/core/task.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/yardstick/benchmark/core/task.py b/yardstick/benchmark/core/task.py
index 395f3b8e8..dd35bd4f4 100644
--- a/yardstick/benchmark/core/task.py
+++ b/yardstick/benchmark/core/task.py
@@ -65,6 +65,8 @@ class Task(object): # pragma: no cover
task_id = getattr(args, 'task_id')
self.task_id = task_id if task_id else str(uuid.uuid4())
+ self._set_log()
+
check_environment()
try:
@@ -156,6 +158,17 @@ class Task(object): # pragma: no cover
print("Done, exiting")
return result
+ def _set_log(self):
+ log_format = '%(asctime)s %(name)s %(filename)s:%(lineno)d %(levelname)s %(message)s'
+ log_formatter = logging.Formatter(log_format)
+
+ log_path = os.path.join(constants.TASK_LOG_DIR, '{}.log'.format(self.task_id))
+ log_handler = logging.FileHandler(log_path)
+ log_handler.setFormatter(log_formatter)
+ log_handler.setLevel(logging.DEBUG)
+
+ logging.root.addHandler(log_handler)
+
def _init_output_config(self, output_config):
output_config.setdefault('DEFAULT', {})
output_config.setdefault('dispatcher_http', {})
@@ -414,7 +427,7 @@ class TaskParser(object): # pragma: no cover
try:
with open(self.path) as stream:
- cfg = yaml.safe_load(stream)
+ cfg = yaml.load(stream)
except IOError as ioerror:
sys.exit(ioerror)
@@ -478,7 +491,7 @@ class TaskParser(object): # pragma: no cover
raise e
print("Input task is:\n%s\n" % rendered_task)
- cfg = yaml.safe_load(rendered_task)
+ cfg = yaml.load(rendered_task)
except IOError as ioerror:
sys.exit(ioerror)