]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/vstart_runner.py: make log initialization code reusable
authorRishabh Dave <ridave@redhat.com>
Mon, 26 Aug 2019 12:14:22 +0000 (17:44 +0530)
committerRishabh Dave <ridave@redhat.com>
Wed, 25 Sep 2019 06:42:00 +0000 (12:12 +0530)
Move it to a method so that the code be can be reused.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
qa/tasks/vstart_runner.py

index fcc09ad8feeb8b79c8bc3372fe8fb90b7ad0b8ac..24be670f8d76c0f401098c5166e3a9477d983656 100644 (file)
@@ -53,15 +53,25 @@ from teuthology.config import config as teuth_config
 
 import logging
 
-log = logging.getLogger(__name__)
-
-handler = logging.FileHandler("./vstart_runner.log")
-formatter = logging.Formatter(
-    fmt=u'%(asctime)s.%(msecs)03d %(levelname)s:%(name)s:%(message)s',
-    datefmt='%Y-%m-%dT%H:%M:%S')
-handler.setFormatter(formatter)
-log.addHandler(handler)
-log.setLevel(logging.INFO)
+def init_log():
+    global log
+    if log is not None:
+        del log
+    log = logging.getLogger(__name__)
+
+    global logpath
+    logpath = './vstart_runner.log'
+
+    handler = logging.FileHandler(logpath)
+    formatter = logging.Formatter(
+        fmt=u'%(asctime)s.%(msecs)03d %(levelname)s:%(name)s:%(message)s',
+        datefmt='%Y-%m-%dT%H:%M:%S')
+    handler.setFormatter(formatter)
+    log.addHandler(handler)
+    log.setLevel(logging.INFO)
+
+log = None
+init_log()
 
 
 def respawn_in_path(lib_path, python_paths):