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"""
32 logging.basicConfig(format='%(funcName)s[%(lineno)d] %(message)s',
33 level=logging.WARNING)
37 def setLogger(logfile, level, formatter):
40 rootLogger = logging.getLogger('')
42 rootLogger.removeHandler(fh)
45 rootLogger.removeHandler(ch)
48 if os.path.exists(logfile):
50 fh = logging.FileHandler(logfile)
51 rootLogger.addHandler(fh)
52 fh.setFormatter(formatter)
54 ch = logging.StreamHandler()
55 rootLogger.addHandler(ch)
56 ch.setFormatter(formatter)
57 rootLogger.setLevel(level)
59 def setDebug(logfile=None):
64 formatter = logging.Formatter('%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s')
65 setLogger(logfile, level, formatter)
66 logging.info('start Debug %s', loglevel)
68 def setVerbose(logfile=None):
73 formatter = logging.Formatter('%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s')
74 setLogger(logfile, level, formatter)
75 logging.info('start Verbose %s', loglevel)
77 def setRelease(logfile=None):
81 level = logging.WARNING
82 formatter = logging.Formatter('%(funcName)s[%(lineno)d] %(message)s')
83 setLogger(logfile, level, formatter)
84 logging.warning('start Release %s', loglevel)
86 def setUnitTests(logfile=None):
90 level = logging.CRITICAL
91 formatter = logging.Formatter('%(funcName)s[%(lineno)d] %(message)s')
92 setLogger(logfile, level, formatter)
93 logging.critical('start UnitTests %s', loglevel)
95 def setPerfTests(logfile=None):
99 level = logging.CRITICAL
100 formatter = logging.Formatter('%(funcName)s[%(lineno)d] %(message)s')
101 setLogger(logfile, level, formatter)
102 logging.info('start PerfTests %s', loglevel)