set dovetail.log level by command line 19/33519/1
authorxudan <xudan16@huawei.com>
Wed, 19 Apr 2017 07:02:16 +0000 (07:02 +0000)
committerxudan <xudan16@huawei.com>
Wed, 19 Apr 2017 07:02:16 +0000 (07:02 +0000)
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>
dovetail/run.py
dovetail/utils/dovetail_logger.py

index 5a902d7..7386790 100755 (executable)
@@ -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']:
index feb7aef..5ad127b 100644 (file)
@@ -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):