从RabbitMQ接收日志

This commit is contained in:
gotoeasy 2022-07-05 15:21:42 +08:00
parent 8b75ce34f9
commit af68b969ca
2 changed files with 5 additions and 3 deletions

View File

@ -32,6 +32,6 @@ func (d *LogDataModel) ToJson() string {
return cmn.BytesToString(bt)
}
func (d *LogDataModel) LoadJson(jsonstr string) {
json.Unmarshal(cmn.StringToBytes(jsonstr), d)
func (d *LogDataModel) LoadJson(jsonstr string) error {
return json.Unmarshal(cmn.StringToBytes(jsonstr), d)
}

View File

@ -63,7 +63,9 @@ func fnAmqpJsonLogHandle(jsonLog string, err error) bool {
md := &logdata.LogDataModel{}
if conf.IsAmqpJsonFormat() {
md.LoadJson(jsonLog)
if md.LoadJson(jsonLog) != nil {
md.Text = jsonLog // 错误的json字符串当文本吃掉
}
} else {
md.Text = jsonLog
}