summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxudan <xudan16@huawei.com>2017-04-19 07:02:16 +0000
committerxudan <xudan16@huawei.com>2017-04-19 07:02:16 +0000
commitb1030e6099f38b226c8ef86a2a4711aca8c1822a (patch)
tree6d8e8b2465fd13af5b6f8dc0421eb81584a15410
parent2ffa3fc85027ef9ac291c6a22bd41bfa2c66ab4c (diff)
set dovetail.log level by command line
JIRA: DOVETAIL-400 1. set both the dovetail.log and screen log level by command --debug. 2. if --report http://testapi_url:port/api/v1/, change it into --report http://testapi_url:port/api/v1 Change-Id: I7cf697d4ac9072fc2d302a67ccde0f452d84be8f Signed-off-by: xudan <xudan16@huawei.com>
-rwxr-xr-xdovetail/run.py2
-rw-r--r--dovetail/utils/dovetail_logger.py15
2 files changed, 10 insertions, 7 deletions
diff --git a/dovetail/run.py b/dovetail/run.py
index 5a902d7f..7386790c 100755
--- a/dovetail/run.py
+++ b/dovetail/run.py
@@ -211,6 +211,8 @@ def main(*args, **kwargs):
dt_cfg.update_config(configs)
if kwargs['report']:
+ if(kwargs['report'].endswith('/')):
+ kwargs['report'] = kwargs['report'][0:kwargs['report'].rfind('/')]
dt_cfg.dovetail_config['report_dest'] = kwargs['report']
if kwargs['offline']:
diff --git a/dovetail/utils/dovetail_logger.py b/dovetail/utils/dovetail_logger.py
index feb7aeff..5ad127ba 100644
--- a/dovetail/utils/dovetail_logger.py
+++ b/dovetail/utils/dovetail_logger.py
@@ -37,22 +37,23 @@ class Logger(object):
self.logger.propagate = 0
self.logger.setLevel(logging.DEBUG)
+ result_path = dt_cfg.dovetail_config['result_dir']
+ if not os.path.exists(result_path):
+ os.makedirs(result_path)
+
ch = logging.StreamHandler(sys.stdout)
formatter = logging.Formatter('%(asctime)s - %(name)s - '
'%(levelname)s - %(message)s')
ch.setFormatter(formatter)
+ hdlr = logging.FileHandler(os.path.join(result_path, 'dovetail.log'))
+ hdlr.setFormatter(formatter)
if DEBUG is not None and DEBUG.lower() == "true":
ch.setLevel(logging.DEBUG)
+ hdlr.setLevel(logging.DEBUG)
else:
ch.setLevel(logging.INFO)
+ hdlr.setLevel(logging.INFO)
self.logger.addHandler(ch)
-
- result_path = dt_cfg.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)
def getLogger(self):