示例#1
0
 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)
     shinken_logger.setLevel(DEBUG)
     self.generic_tst(lambda x: naglog_result('info', x), 'Some log-message',
                      [1, 1], [r'^\[\d+\] Some log-message\n$', r'^\[\d+\] Some log-message$'])
示例#2
0
    def check_and_log_activation_change(self):
        now = int(time.time())

        was_active = self.is_active
        self.is_active = self.is_time_valid(now)

        # If we got a change, log it!
        if self.is_active != was_active:
            _from = 0
            _to = 0
            # If it's the start, get a special value for was
            if was_active is None:
                _from = -1
            if was_active:
                _from = 1
            if self.is_active:
                _to = 1

            # Now raise the log
            naglog_result("info", "TIMEPERIOD TRANSITION: %s;%d;%d" % (self.get_name(), _from, _to))
示例#3
0
 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)
     shinken_logger.setLevel(DEBUG)
     self.generic_tst(
         lambda x: naglog_result('info', x), 'Some log-message', [1, 1],
         [r'^\[\d+\] Some log-message\n$', r'^\[\d+\] Some log-message$'])
示例#4
0
    def check_and_log_activation_change(self):
        now = int(time.time())

        was_active = self.is_active
        self.is_active = self.is_time_valid(now)

        # If we got a change, log it!
        if self.is_active != was_active:
            _from = 0
            _to = 0
            # If it's the start, get a special value for was
            if was_active is None:
                _from = -1
            if was_active:
                _from = 1
            if self.is_active:
                _to = 1

            # Now raise the log
            naglog_result('info', 'TIMEPERIOD TRANSITION: %s;%d;%d'
                                % (self.get_name(), _from, _to))
示例#5
0
 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
 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
 def raise_cancel_downtime_log_entry(self):
     naglog_result(
         'info', "CONTACT DOWNTIME ALERT: %s;CANCELLED; Scheduled "
         "downtime for contact has been cancelled." % self.get_name())
示例#8
0
 def raise_exit_downtime_log_entry(self):
     naglog_result(
         'info', "CONTACT DOWNTIME ALERT: %s;STOPPED; Contact has "
         "exited from a period of scheduled downtime" % self.get_name())
示例#9
0
 def raise_enter_downtime_log_entry(self):
     naglog_result(
         'info', "CONTACT DOWNTIME ALERT: %s;STARTED; Contact has "
         "entered a period of scheduled downtime" % self.get_name())
示例#10
0
 def raise_cancel_downtime_log_entry(self):
     naglog_result('info', "CONTACT DOWNTIME ALERT: %s;CANCELLED; Scheduled "
                         "downtime for contact has been cancelled."
                         % self.get_name())
示例#11
0
 def raise_exit_downtime_log_entry(self):
     naglog_result('info', "CONTACT DOWNTIME ALERT: %s;STOPPED; Contact has "
                         "exited from a period of scheduled downtime"
                         % self.get_name())
示例#12
0
 def raise_enter_downtime_log_entry(self):
     naglog_result('info', "CONTACT DOWNTIME ALERT: %s;STARTED; Contact has "
                         "entered a period of scheduled downtime"
                         % self.get_name())