Salome HOME
general crack dialog: working on log...
[modules/smesh.git] / src / Tools / blocFissure / gmu / initLog.py
index adbdda00b40fbdd5168a70237ed617bc06f17a19..bc427de1d3c0aedc04556887cc825e1c8c63deb2 100644 (file)
@@ -1,41 +1,78 @@
 # -*- coding: utf-8 -*-
 
 import logging
-loglevel = 3
 
-def setDebug():
+debug = 10
+info = 20
+warning = 30
+error = 40
+critical = 50
+
+loglevel = warning
+
+def setDebug(logfile=None):
   global loglevel
-  logging.basicConfig(format='%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s',
-                      level=logging.DEBUG)
-  loglevel = 1
+  logging.shutdown()
+  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)
-  loglevel = 2
+  logging.shutdown()
+  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)
-  loglevel = 3
+  logging.shutdown()
+  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)
-  loglevel = 4
+  logging.shutdown()
+  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)
-  loglevel = 5
+  logging.shutdown()
+  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)
   
 def getLogLevel():