src/alert.py
def __send_alert(self, tokens: Dict[str, Any], line: str) -> None:
        """
        Sends an alert if it's not in the grace_time and if it happened at
        least min_occurrences
        """
        ident = self._identifier.format(**tokens)
        msg = self._message.format(**tokens)
        try:
            self._occurrence[ident] += 1
        except KeyError:
            self._occurrence[ident] = 1

        if self._occurrence[ident] < self._min_occurrences:
            logging.debug(
                f'skipping message "{msg}", line "{line}" '
                f'because number of occurences '
                f'{self._occurrence[ident]} is less '
                f'than the minimum {self._min_occurrences}'
            )
            return

        if ident not in self._end_grace or \
                self._end_grace[ident] < datetime.now():
            self._end_grace[ident] = datetime.now() + self._grace
            self._channel.alert(msg, line)
            self._occurrence[ident] = 0
        else:
            logging.debug(
                f'skipping message "{msg}", line {line} because in grace '
                f'period till {self._end_grace[ident]}'
            )

        Sends an alert if it's not in the grace_time and if it happened at
        least min_occurrences
        
Sends an alert if it's not in the grace_time and if it happened at
least min_occurrences
Sends an alert if it ' s not in the grace_time and if it happened at least min_occurrences
def __send_alert(self, tokens: Dict[str, Any], line: str) -> None:
        ident = self._identifier.format(**tokens)
        msg = self._message.format(**tokens)
        try:
            self._occurrence[ident] += 1
        except KeyError:
            self._occurrence[ident] = 1
        if self._occurrence[ident] < self._min_occurrences:
            logging.debug(
                f'skipping message "{msg}", line "{line}" '
                f'because number of occurences '
                f'{self._occurrence[ident]} is less '
                f'than the minimum {self._min_occurrences}'
            )
            return
        if ident not in self._end_grace or \
                self._end_grace[ident] < datetime.now():
            self._end_grace[ident] = datetime.now() + self._grace
            self._channel.alert(msg, line)
            self._occurrence[ident] = 0
        else:
            logging.debug(
                f'skipping message "{msg}", line {line} because in grace '
                f'period till {self._end_grace[ident]}'
            )
def __send_alert ( self , tokens : Dict [ str , Any ] , line : str ) -> None : ident = self . _identifier . format ( ** tokens ) msg = self . _message . format ( ** tokens ) try : self . _occurrence [ ident ] += 1 except KeyError : self . _occurrence [ ident ] = 1 if self . _occurrence [ ident ] < self . _min_occurrences : logging . debug ( f'skipping message "{msg}", line "{line}" ' f'because number of occurences ' f'{self._occurrence[ident]} is less ' f'than the minimum {self._min_occurrences}' ) return if ident not in self . _end_grace or self . _end_grace [ ident ] < datetime . now ( ) : self . _end_grace [ ident ] = datetime . now ( ) + self . _grace self . _channel . alert ( msg , line ) self . _occurrence [ ident ] = 0 else : logging . debug ( f'skipping message "{msg}", line {line} because in grace ' f'period till {self._end_grace[ident]}' )
Sends an alert if it's not in the grace_time and if it happened at
least min_occurrences
Sends an alert if it ' s not in the grace_time and if it happened at least min_occurrences
"""
        Sends an alert if it's not in the grace_time and if it happened at
        least min_occurrences
        """
self
tokens
Dict[str, Any]
line
str