put logfile setting up prior to other error output
authorGui Chen <gui.chen@intel.com>
Mon, 19 May 2014 05:41:14 +0000 (01:41 -0400)
committeradmin <yuhuan.yang@samsung.com>
Thu, 4 Feb 2016 10:09:44 +0000 (18:09 +0800)
except release optioin applied

Change-Id: I10eaac322424460694566a79eda5e53642d798fe
Signed-off-by: Gui Chen <gui.chen@intel.com>
mic/conf.py
mic/creator.py

index a945f6a..b4aa235 100644 (file)
@@ -219,17 +219,7 @@ class ConfigMgr(object):
                 self.create['logfile'] = os.path.join(self.create['outdir'],
                                                       self.create['name'] + ".log")
                 self.create['releaselog'] = True
-
-        if self.create['logfile']:
-            logfile_dir = os.path.dirname(self.create['logfile'])
-            if not os.path.exists(logfile_dir):
-                os.makedirs(logfile_dir)
-            msger.set_interactive(False)
-            if inbootstrap():
-                mode = 'a'
-            else:
-                mode = 'w'
-            msger.set_logfile(self.create['logfile'], mode)
+                self.set_logfile()
 
         msger.info("Retrieving repo metadata:")
         ksrepos = kickstart.get_repos(ks,
@@ -270,6 +260,20 @@ class ConfigMgr(object):
         misc.selinux_check(self.create['arch'],
                            [p.fstype for p in ks.handler.partition.partitions])
 
+    def set_logfile(self, logfile = None):
+        if not logfile:
+            logfile = self.create['logfile']
+
+        logfile_dir = os.path.dirname(self.create['logfile'])
+        if not os.path.exists(logfile_dir):
+            os.makedirs(logfile_dir)
+        msger.set_interactive(False)
+        if inbootstrap():
+            mode = 'a'
+        else:
+            mode = 'w'
+        msger.set_logfile(self.create['logfile'], mode)
+
     def set_runtime(self, runtime):
         if runtime not in ("bootstrap", "native"):
             raise errors.CreatorError("Invalid runtime mode: %s" % runtime)
index b21ebda..dde1013 100644 (file)
@@ -183,6 +183,7 @@ class Creator(cmdln.Cmdln):
                 raise errors.Usage("logfile's path %s should be file"
                                    % self.options.logfile)
             configmgr.create['logfile'] = logfile_abs_path
+            configmgr.set_logfile()
 
         if self.options.config:
             configmgr.reset()