(self, record)
Aggregate stats if needed, and send to logdb.
Aggregate stats if needed, and send to logdb.
Aggregate stats if needed and send to logdb .
def process_rec(self, record):
        """Aggregate stats if needed, and send to logdb."""
        # render msg
        msg = self.format(record)

        # dont want to send stats too ofter
        if record.levelno == logging.INFO and msg and msg[0] == "{":
            self.aggregate_stats(msg)
            if time.time() - self.last_stat_flush >= self.stat_flush_period:
                self.flush_stats(_job_name)
            return

        if record.levelno < logging.INFO:
            self.flush_stats(_job_name)

        # dont send more than one line
        ln = msg.find('\n')
        if ln > 0:
            msg = msg[:ln]

        txt_level = self._level_map.get(record.levelno, "ERROR")
        self.send_to_logdb(_job_name, txt_level, msg)
def process_rec ( self , record ) : # render msg msg = self . format ( record ) # dont want to send stats too ofter if record . levelno == logging . INFO and msg and msg [ 0 ] == "{" : self . aggregate_stats ( msg ) if time . time ( ) - self . last_stat_flush >= self . stat_flush_period : self . flush_stats ( _job_name ) return if record . levelno < logging . INFO : self . flush_stats ( _job_name ) # dont send more than one line ln = msg . find ( '\n' ) if ln > 0 : msg = msg [ : ln ] txt_level = self . _level_map . get ( record . levelno , "ERROR" ) self . send_to_logdb ( _job_name , txt_level , msg )