handler.py 文件源码

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

项目:logzio-python-handler 作者: logzio 项目源码 文件源码
def format_message(self, message):
        now = datetime.datetime.utcnow()
        timestamp = now.strftime("%Y-%m-%dT%H:%M:%S") + ".%03d" % (now.microsecond / 1000) + "Z"

        return_json = {
            "logger": message.name,
            "line_number": message.lineno,
            "path_name": message.pathname,
            "log_level": message.levelname,
            "type": self.logzio_type,
            "message": message.getMessage(),
            "@timestamp": timestamp
        }

        if message.exc_info:
            return_json["exception"] = self.format_exception(message.exc_info)
        else:
            formatted_message = self.format(message)
            if isinstance(formatted_message, dict):
                return_json.update(formatted_message)
            else:
                return_json["message"] = formatted_message

        return return_json
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号