summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dovetail/utils/dovetail_logger.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/dovetail/utils/dovetail_logger.py b/dovetail/utils/dovetail_logger.py
index bd13508d..9cd8719b 100644
--- a/dovetail/utils/dovetail_logger.py
+++ b/dovetail/utils/dovetail_logger.py
@@ -24,6 +24,18 @@
import logging
import os
+from conf.dovetail_config import dovetail_config
+import dovetail_utils as dt_utils
+
+
+def clean_results_dir():
+ result_path = dovetail_config['result_dir']
+ if os.path.exists(result_path):
+ cmd = 'sudo rm -rf %s' % (result_path)
+ dt_utils.exec_cmd(cmd)
+
+clean_results_dir()
+
class Logger:
def __init__(self, logger_name):
@@ -44,9 +56,10 @@ class Logger:
ch.setLevel(logging.INFO)
self.logger.addHandler(ch)
- if not os.path.exists('/home/opnfv/dovetail/results/'):
- os.makedirs('/home/opnfv/dovetail/results/')
- hdlr = logging.FileHandler('/home/opnfv/dovetail/results/dovetail.log')
+ result_path = dovetail_config['result_dir']
+ if not os.path.exists(result_path):
+ os.makedirs(result_path)
+ hdlr = logging.FileHandler(os.path.join(result_path, 'dovetail.log'))
hdlr.setFormatter(formatter)
hdlr.setLevel(logging.DEBUG)
self.logger.addHandler(hdlr)