Logs.py 文件源码

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

项目:SoCFoundationFlow 作者: mattaw 项目源码 文件源码
def emit_override(self, record, **kw):
        self.terminator = getattr(record, 'terminator', '\n')
        stream = self.stream
        if unicode:
            # python2
            msg = self.formatter.format(record)
            fs = '%s' + self.terminator
            try:
                if (isinstance(msg, unicode) and getattr(stream, 'encoding', None)):
                    fs = fs.decode(stream.encoding)
                    try:
                        stream.write(fs % msg)
                    except UnicodeEncodeError:
                        stream.write((fs % msg).encode(stream.encoding))
                else:
                    stream.write(fs % msg)
            except UnicodeError:
                stream.write((fs % msg).encode("UTF-8"))
        else:
            logging.StreamHandler.emit(self, record)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号