Exemplo n.º 1
0
    def lastlog(self, lines=20, format='', html=True):
        handler = self._loghandler
        if format:
            formatter = ColoredFormatter(format, datefmt=self.time_format)
        else:
            formatter = ColoredFormatter(
                self.html_format if html else self.format,
                datefmt=self.time_format)

        rv = u'\n'.join([formatter.format(i) for i in handler.buffer[-lines:]])

        if html:
            rv = ansiconv.to_html(self.html_fix(rv))
        else:
            rv = ansiconv.to_plain(rv)
        return rv
Exemplo n.º 2
0
    def format(self, record):
        """Format log record."""
        # Save the original format configured by the user
        # when the logger formatter was instantiated
        format_orig = self._style._fmt

        # Replace the original format with one customized by logging level
        if "message repeated" in str(record.msg):
            self._style._fmt = self.overwrite_fmt

        # Call the original formatter class to do the grunt work
        result = ColoredFormatter.format(self, record)

        # Restore the original format configured by the user
        self._style._fmt = format_orig

        return result
Exemplo n.º 3
0
Arquivo: log.py Projeto: bolaum/agentk
 def format(self, record):
     record.adjustedTime = record.relativeCreated / 1000.0
     return ColoredFormatter.format(self, record)