Пример #1
0
    def __call__(self, *messages, level='INFO', tb=''):
        """ Logging messages to logfile under level given """
        try:
            self.__lock.acquire()
            if not tb:
                tb = get_caller(1)
            msg = ' '.join(map(lambda x: str(x), messages))
            if '\n' in msg:
                for s in msg.split('\n'):
                    self.__log[level](tb + s)
                    self.__nlines += 1
                    self.__nlevel[level] += 1
            else:
                self.__log[level](tb + msg)
                self.__nlines += 1
                self.__nlevel[level] += 1

        except KeyError:
            raise KeyError(level, 'is not a valid level')

        finally:
            self.__lock.release()
Пример #2
0
 def error(self, *messages):
     self.__call__(*messages, level='ERROR', tb=get_caller(1))
Пример #3
0
 def fatal(self, *messages):
     self.__call__(*messages, level='FATAL', tb=get_caller(1))
Пример #4
0
 def warn(self, *messages):
     self.__call__(*messages, level='WARN', tb=get_caller(1))
Пример #5
0
 def info(self, *messages):
     self.__call__(*messages, level='INFO', tb=get_caller(1))
Пример #6
0
 def debug(self, *messages):
     self.__call__(*messages, level='DEBUG', tb=get_caller(1))
Пример #7
0
 def record(self, dictargs):
     """ Multi record """
     for msg, lv in dictargs.items():
         self.__call__(msg, level=lv, tb=get_caller(1))
Пример #8
0
 def test_system_and_rt(self):
     self.assertEqual("[test_system_and_rt] ", get_caller(0))
     self.assertEqual("[run] ", get_caller(1))
     conf = reconfig()
     self.assertEqual(conf['old gc.threshold'], str(DEFAULT_GC_THRESHOLD))
     self.assertEqual(conf['sys.platform'], 'linux')