+ # Sometimes other users will make 'sat log' and update this file
+ os.chmod(xmlHatFilePath,
+ stat.S_IRUSR |
+ stat.S_IRGRP |
+ stat.S_IROTH |
+ stat.S_IWUSR |
+ stat.S_IWGRP |
+ stat.S_IWOTH )
+
+
+
+# TODO for future
+# prepare skip to logging logger sat5.1
+# suppose only one logger in sat5.1
+_currentLogger = []
+
+def getCurrentLogger():
+ """get current logging logger, set as DefaultLogger if not set yet"""
+ if len(_currentLogger) == 0:
+ import src.loggingSimple as LOGSI
+ logger = LOGSI.getDefaultLogger()
+ _currentLogger.append(logger)
+ logger.warning("set by default current logger as %s" % logger.name)
+ return _currentLogger[0]
+
+def getDefaultLogger():
+ """get simple logging logger DefaultLogger, set it as current"""
+ import src.loggingSimple as LOGSI
+ logger = LOGSI.getDefaultLogger()
+ setCurrentLogger(logger) # set it as current
+ return logger
+
+def getUnittestLogger():
+ """get simple logging logger UnittestLogger, set it as current"""
+ import src.loggingSimple as LOGSI
+ logger = LOGSI.getUnittestLogger()
+ setCurrentLogger(logger) # set it as current
+ return logger
+
+def setCurrentLogger(logger):
+ """temporary send all in stdout as simple logging logger"""
+ if len(_currentLogger) == 0:
+ _currentLogger.append(logger)
+ logger.debug("set current logger as %s" % logger.name)
+ else:
+ if _currentLogger[0].name != logger.name:
+ # logger.debug("quit current logger as default %s" % _currentLogger[0].name)
+ _currentLogger[0] = logger
+ logger.warning("change current logger as %s" % logger.name)
+ return _currentLogger[0]
+
+def isCurrentLoggerUnittest():
+ logger = getCurrentLogger()
+ if "Unittest" in logger.name:
+ res = True
+ else:
+ res = False
+ #DBG.write("isCurrentLoggerUnittest %s" % logger.name, res)
+ return res
+
+def sendMessageToCurrentLogger(message, level):
+ """
+ assume relay from obsolescent
+ logger.write(msg, 1/2/3...) to future
+ logging.critical/warning/info...(msg) (as logging package tips)
+ """
+ logger = getCurrentLogger()
+ if level is None:
+ lev = 2
+ else:
+ lev = level
+ if lev <= 1:
+ logger.critical(message)
+ return
+ if lev == 2:
+ logger.warning(message)
+ return
+ if lev == 3:
+ logger.info(message)
+ return
+ if lev == 4:
+ logger.step(message)
+ return
+ if lev == 5:
+ logger.trace(message)
+ return
+ if lev >= 6:
+ logger.debug(message)
+ return
+ msg = "What is this level: '%s' for message:\n%s" % (level, message)
+ logger.warning(msg)
+ return