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
评论列表
文章目录