コード例 #1
0
ファイル: test_logging.py プロジェクト: adenir2202/shinken
 def _prepare_logging(self):
     super(TestWithLocalLogging, self)._prepare_logging()
     # set up a temporary file for logging
     logfile = NamedTemporaryFile("w")
     logfile.close()
     self.logfile_name = logfile.name
     logger.register_local_log(logfile.name)
コード例 #2
0
 def _prepare_logging(self):
     super(TestWithLocalLogging, self)._prepare_logging()
     # set up a temporary file for logging
     logfile = NamedTemporaryFile("w")
     logfile.close()
     self.logfile_name = logfile.name
     logger.register_local_log(logfile.name)
コード例 #3
0
 def test_register_local_log_keeps_level(self):
     logger.set_level(logger.ERROR)
     self.assertEqual(logger._level, logger.ERROR)
     logfile = NamedTemporaryFile("w")
     logfile.close()
     logfile_name = logfile.name
     logger.register_local_log(logfile_name)
     self.assertEqual(logger._level, logger.ERROR)
コード例 #4
0
ファイル: test_logging.py プロジェクト: adenir2202/shinken
 def test_register_local_log_keeps_level(self):
     logger.set_level(logger.ERROR)
     self.assertEqual(logger._level, logger.ERROR)
     logfile = NamedTemporaryFile("w")
     logfile.close()
     logfile_name = logfile.name
     logger.register_local_log(logfile_name)
     self.assertEqual(logger._level, logger.ERROR)
コード例 #5
0
ファイル: test_logging.py プロジェクト: FlorianLudwig/shinken
 def test_basic_logging_log(self):
     sys.stdout = StringIO()
     self._collector = Collector()
     sh = StreamHandler(sys.stdout)
     sh.setFormatter(defaultFormatter)
     shinken_logger.handlers = []
     shinken_logger.addHandler(sh)
     shinken_logger.load_obj(self._collector)
     logfile = NamedTemporaryFile("w", delete=False)
     logfile.close()
     self.logfile_name = logfile.name
     shinken_logger.register_local_log(logfile.name)
     shinken_logger.setLevel(DEBUG)
     self.generic_tst(lambda x: naglog_result('info', x), 'Some log-message',
                      [1, 1, 1], ['', r'^\[\d+\] Some log-message$', r'^\[\d+\] Some log-message$'])
コード例 #6
0
ファイル: test_logging.py プロジェクト: zxahu/shinken
 def test_basic_logging_log(self):
     sys.stdout = StringIO()
     self._collector = Collector()
     sh = StreamHandler(sys.stdout)
     sh.setFormatter(defaultFormatter)
     shinken_logger.handlers = []
     shinken_logger.addHandler(sh)
     shinken_logger.load_obj(self._collector)
     logfile = NamedTemporaryFile("w", delete=False)
     logfile.close()
     self.logfile_name = logfile.name
     shinken_logger.register_local_log(logfile.name)
     shinken_logger.setLevel(DEBUG)
     self.generic_tst(
         lambda x: naglog_result('info', x), 'Some log-message', [1, 1, 1],
         ['', r'^\[\d+\] Some log-message$', r'^\[\d+\] Some log-message$'])
コード例 #7
0
ファイル: test_logging.py プロジェクト: cedef/shinken
 def test_none_logrotation(self):
     self._prepare_logging()
     shinken_logger.register_local_log(self.logfile_name, purge_buffer=False, log_rotation_method='n')
     self.assertIsInstance(shinken_logger.handlers[-1], logging.FileHandler)
コード例 #8
0
ファイル: test_logging.py プロジェクト: cedef/shinken
 def test_weekly_logrotation(self):
     self._prepare_logging()
     shinken_logger.register_local_log(self.logfile_name, purge_buffer=False, log_rotation_method='w')
     self.assertIsInstance(shinken_logger.handlers[-1], logging.handlers.TimedRotatingFileHandler)
     self.assertEqual(shinken_logger.handlers[-1].when, 'W5')