From 4370e1798b3d94dde48a7b878ea73f29d9782c49 Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Fri, 26 Feb 2016 21:05:40 +0100 Subject: [PATCH] general crack dialog, save log in file --- src/Tools/blocFissure/gmu/initLog.py | 55 ++++++++++++++----- .../blocFissure/ihm/fissureGenerale_plugin.py | 11 ++-- 2 files changed, 46 insertions(+), 20 deletions(-) diff --git a/src/Tools/blocFissure/gmu/initLog.py b/src/Tools/blocFissure/gmu/initLog.py index 07c0c3640..c9c78b30c 100644 --- a/src/Tools/blocFissure/gmu/initLog.py +++ b/src/Tools/blocFissure/gmu/initLog.py @@ -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) diff --git a/src/Tools/blocFissure/ihm/fissureGenerale_plugin.py b/src/Tools/blocFissure/ihm/fissureGenerale_plugin.py index c8c495abe..9e602ed68 100644 --- a/src/Tools/blocFissure/ihm/fissureGenerale_plugin.py +++ b/src/Tools/blocFissure/ihm/fissureGenerale_plugin.py @@ -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) -- 2.39.2