(self, record)
return message
Format a message from a record object.
Format a message from a record object.
Format a message from a record object .
def format(self, record):
        """Format a message from a record object."""
        record = LightbusLogRecord(record)
        record.log_color = self.color(self.log_colors, record.levelname)
        record.is_tty = self.stream.isatty()

        # Set secondary log colors
        if self.secondary_log_colors:
            for name, log_colors in self.secondary_log_colors.items():
                color = self.color(log_colors, record.levelname)
                setattr(record, name + "_log_color", color)

        # Set format for this particular log level
        if isinstance(self.fmt, dict):
            self._fmt = self.fmt[record.levelname]
            # Update self._style because we've changed self._fmt
            # (code based on stdlib's logging.Formatter.__init__())
            if self.style not in logging._STYLES:
                raise ValueError("Style must be one of: %s" % ",".join(logging._STYLES.keys()))
            self._style = logging._STYLES[self.style][0](self._fmt)

        # Format the message
        record.additional_line_prefix = self.get_additional_line_prefix(record)
        message = super(LightbusFormatter, self).format(record)

        # Add a reset code to the end of the message
        # (if it wasn't explicitly added in format str)
        if self.reset and not message.endswith(escape_codes["reset"]):
            message += escape_codes["reset"]

        return message
def format ( self , record ) : record = LightbusLogRecord ( record ) record . log_color = self . color ( self . log_colors , record . levelname ) record . is_tty = self . stream . isatty ( ) # Set secondary log colors if self . secondary_log_colors : for name , log_colors in self . secondary_log_colors . items ( ) : color = self . color ( log_colors , record . levelname ) setattr ( record , name + "_log_color" , color ) # Set format for this particular log level if isinstance ( self . fmt , dict ) : self . _fmt = self . fmt [ record . levelname ] # Update self._style because we've changed self._fmt # (code based on stdlib's logging.Formatter.__init__()) if self . style not in logging . _STYLES : raise ValueError ( "Style must be one of: %s" % "," . join ( logging . _STYLES . keys ( ) ) ) self . _style = logging . _STYLES [ self . style ] [ 0 ] ( self . _fmt ) # Format the message record . additional_line_prefix = self . get_additional_line_prefix ( record ) message = super ( LightbusFormatter , self ) . format ( record ) # Add a reset code to the end of the message # (if it wasn't explicitly added in format str) if self . reset and not message . endswith ( escape_codes [ "reset" ] ) : message += escape_codes [ "reset" ] return message