logs.py 文件源码

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

项目:talisker 作者: canonical-ols 项目源码 文件源码
def logfmt_key(self, k):
        if isinstance(k, bytes):
            k = k.decode('utf8')

        if isinstance(k, str):
            k = k.replace(' ', '_').replace('.', '_').replace('=', '_')
            k = self.safe_string(k, self.MAX_KEY_SIZE, self.TRUNCATED_KEY)
            # TODO: look at measuring perf of this
            # ' ' and = are replaced because they're are not valid logfmt
            # . is replaced because elasticsearch can't do keys with . in
        elif isinstance(k, bool):
            # need to do this here, as bool are also numbers
            return None
        elif isinstance(k, numbers.Number):
            k = str(k)
        else:
            return None

        return k
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号