]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
general crack dialog, save log in file
authorPaul RASCLE <paul.rascle@edf.fr>
Fri, 26 Feb 2016 20:05:40 +0000 (21:05 +0100)
committerPaul RASCLE <paul.rascle@edf.fr>
Fri, 26 Feb 2016 20:05:40 +0000 (21:05 +0100)
src/Tools/blocFissure/gmu/initLog.py
src/Tools/blocFissure/ihm/fissureGenerale_plugin.py

index 07c0c36407f3795db00c629f84e3c08ddba33d23..c9c78b30c42266c06f561435391ee04ccc488eaf 100644 (file)
@@ -10,38 +10,63 @@ critical = 50
 
 loglevel = warning
 
-def setDebug():
+def setDebug(logfile=None):
   global loglevel
-  logging.basicConfig(format='%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s',
-                      level=logging.DEBUG)
+  if logfile:
+    logging.basicConfig(filename=logfile,
+                        format='%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s',
+                        level=logging.DEBUG)
+  else:
+    logging.basicConfig(format='%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s',
+                        level=logging.DEBUG)    
   loglevel = debug
   logging.info('start Debug %s', loglevel)
 
-def setVerbose():
+def setVerbose(logfile=None):
   global loglevel
-  logging.basicConfig(format='%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s',
-                      level=logging.INFO)
+  if logfile:
+    logging.basicConfig(filename=logfile,
+                        format='%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s',
+                        level=logging.INFO)
+  else:
+    logging.basicConfig(format='%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s',
+                        level=logging.INFO)    
   loglevel = info
   logging.info('start Verbose %s', loglevel)
 
-def setRelease():
+def setRelease(logfile=None):
   global loglevel
-  logging.basicConfig(format='%(funcName)s[%(lineno)d] %(message)s',
-                      level=logging.WARNING)
+  if logfile:
+    logging.basicConfig(filename=logfile,
+                        format='%(funcName)s[%(lineno)d] %(message)s',
+                        level=logging.WARNING)
+  else:
+    logging.basicConfig(format='%(funcName)s[%(lineno)d] %(message)s',
+                        level=logging.WARNING)
   loglevel = warning
   logging.warning('start Release %s', loglevel)
   
-def setUnitTests():
+def setUnitTests(logfile=None):
   global loglevel
-  logging.basicConfig(format='%(funcName)s[%(lineno)d] %(message)s',
-                      level=logging.CRITICAL)
+  if logfile:
+    logging.basicConfig(filename=logfile,
+                        format='%(funcName)s[%(lineno)d] %(message)s',
+                        level=logging.CRITICAL)
+  else:
+    logging.basicConfig(format='%(funcName)s[%(lineno)d] %(message)s',
+                        level=logging.CRITICAL)
   loglevel = critical
   logging.critical('start UnitTests %s', loglevel)
   
-def setPerfTests():
+def setPerfTests(logfile=None):
   global loglevel
-  logging.basicConfig(format='%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s',
-                      level=logging.CRITICAL)
+  if logfile:
+    logging.basicConfig(filename=logfile,
+                        format='%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s',
+                        level=logging.CRITICAL)
+  else:
+    logging.basicConfig(format='%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s',
+                        level=logging.CRITICAL)    
   loglevel = critical
   logging.info('start PerfTests %s', loglevel)
   
index c8c495abe7b554a216000e7f5beb83fa516c1501..9e602ed68c488399f3f16ee733d33cdd34c11ad1 100644 (file)
@@ -198,17 +198,17 @@ def fissureGeneraleDlg(context):
       #self.initDefaut()
       self.initDialog(self.defaut)
       
-    def setLogVerbosity(self):
+    def setLogVerbosity(self, logfile):
       from blocFissure.gmu import initLog # le mode de log s'initialise une seule fois
       print "setLogVerbosity"
       index = self.ui.cb_log.currentIndex()
       print index
       if index == 0:
-        initLog.setRelease()
+        initLog.setRelease(logfile)
       elif index == 1:
-        initLog.setVerbose()
+        initLog.setVerbose(logfile)
       elif index == 2:
-        initLog.setDebug()
+        initLog.setDebug(logfile)
       
       
     def sauver(self):
@@ -321,7 +321,8 @@ def fissureGeneraleDlg(context):
       if not(NOK):
         self.writeDefault(dico)
         self.ui.lb_calcul.show()
-        self.setLogVerbosity()
+        logfile=os.path.join(dico['reptrav'], dico['nomres']+".log")
+        self.setLogVerbosity(logfile)
         from blocFissure.gmu import geomsmesh               # après intialisation log dans setLogVerbosity
         from blocFissure.gmu.casStandard import casStandard # après intialisation log dans setLogVerbosity
         execInstance = casStandard(dico)