loggie-io / loggie

A lightweight, cloud-native data transfer agent and aggregator
https://loggie-io.github.io/docs-en/
Apache License 2.0
1.26k stars 167 forks source link

fix(interceptor): Optimizes maxbytes interceptions #575

Closed kytool closed 1 year ago

kytool commented 1 year ago

Proposed Changes:

Which issue(s) this PR fixes:

当前:maxbytes配置的是字节长度,截取的时候当成字符长度,比如body=我爱祖国啊,maxbytes=4,截取后变成我爱祖国,截取后字节长度就变成12了 如果按照字节长度截取,则截取后变成我�,发送到es时则报错:Invalid UTF-8 middle byte

现在优化为:按照字节长度截取,如果最后一个字节非utf8字节结尾则往后取,即截取后为我爱