1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2021 EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 """Initialisations des impressions"""
33 LOGFILE = os.path.join(tempfile.gettempdir(),"blocFissure.log")
37 logging.basicConfig(format='%(funcName)s[%(lineno)d] %(message)s', \
38 level=logging.WARNING, \
39 filename=LOGFILE, filemode='w')
43 def setLogger(logfile, level, formatter):
46 rootLogger = logging.getLogger('')
48 rootLogger.removeHandler(fh)
51 rootLogger.removeHandler(ch)
54 if os.path.exists(logfile):
56 fh = logging.FileHandler(logfile)
57 rootLogger.addHandler(fh)
58 fh.setFormatter(formatter)
60 ch = logging.StreamHandler()
61 rootLogger.addHandler(ch)
62 ch.setFormatter(formatter)
63 rootLogger.setLevel(level)
65 def setDebug(logfile=None):
70 formatter = logging.Formatter('%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s')
71 setLogger(logfile, level, formatter)
72 logging.info('start Debug %s', LOG_LEVEL)
74 def setVerbose(logfile=None):
79 formatter = logging.Formatter('%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s')
80 setLogger(logfile, level, formatter)
81 logging.info('start Verbose %s', LOG_LEVEL)
83 def setRelease(logfile=None):
87 level = logging.WARNING
88 formatter = logging.Formatter('%(funcName)s[%(lineno)d] %(message)s')
89 setLogger(logfile, level, formatter)
90 logging.warning('start Release %s', LOG_LEVEL)
92 def setUnitTests(logfile=None):
96 level = logging.CRITICAL
97 formatter = logging.Formatter('%(funcName)s[%(lineno)d] %(message)s')
98 setLogger(logfile, level, formatter)
99 logging.critical('start UnitTests %s', LOG_LEVEL)
101 def setPerfTests(logfile=None):
105 level = logging.CRITICAL
106 formatter = logging.Formatter('%(funcName)s[%(lineno)d] %(message)s')
107 setLogger(logfile, level, formatter)
108 logging.info('start PerfTests %s', LOG_LEVEL)
110 def setAlways(logfile=None):
114 level = logging.CRITICAL
115 formatter = logging.Formatter('%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s')
116 setLogger(logfile, level, formatter)
117 logging.info('start Always %s', LOG_LEVEL)