logger.py 文件源码

python
阅读 44 收藏 0 点赞 0 评论 0

项目:two1-python 作者: 21dotco 项目源码 文件源码
def format(self, record):
        """ Formats the record.msg string by using click.style()

            The record will have attributes set to it when a user logs a message
            with any kwargs given. This function looks for any attributes that
            are in STYLES. If record has any sytle attributes, the record will
            be styled with the given sytle. This makes click logging with a logger very easy.

        Args:
            record (logging.LogRecord): record which gets styled with click.style()
        """
        # Sets the default kwargs
        kwargs = dict()

        # checks if any click args were passed along in the logger
        for kwarg_name in self.STYLES:
            if hasattr(record, kwarg_name):
                kwargs[kwarg_name] = getattr(record, kwarg_name)

        # styles the message of the record if a style was given
        if kwargs:
            record.msg = click.style(record.msg, **kwargs)

        return record
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号