Commit e25aa53c authored by 李世星's avatar 李世星

fix(修改日志打印): 202302131544

parent 04f692e9
...@@ -2,7 +2,9 @@ package ding ...@@ -2,7 +2,9 @@ package ding
import ( import (
"bytes" "bytes"
"encoding/json"
"fmt" "fmt"
"reflect"
"time" "time"
"github.com/y7ut/logtransfer/entity" "github.com/y7ut/logtransfer/entity"
...@@ -75,6 +77,17 @@ func pluginNotice(msg interface{}) string { ...@@ -75,6 +77,17 @@ func pluginNotice(msg interface{}) string {
templateBuff := bytes.NewBuffer([]byte{}) templateBuff := bytes.NewBuffer([]byte{})
templateBuff.WriteString(fmt.Sprintf("# 服务通知 \r\n > 【节点】:%s", mateData.SourceAgent)) templateBuff.WriteString(fmt.Sprintf("# 服务通知 \r\n > 【节点】:%s", mateData.SourceAgent))
for key, value := range mateData.Data { for key, value := range mateData.Data {
t := reflect.TypeOf(value).Kind().String()
if t == "map" {
s, _ := json.Marshal(value)
value = string(s)
}
if t == "float64" {
value = fmt.Sprintf("%.0f", value)
}
if t == "slice" {
value = fmt.Sprintf("%v", value)
}
templateBuff.WriteString(fmt.Sprintf(" \r\n > 【%s】:%s", key, value)) templateBuff.WriteString(fmt.Sprintf(" \r\n > 【%s】:%s", key, value))
} }
templateBuff.WriteString(fmt.Sprintf(" \r\n ###### %s", time.Now().Format("2006/01/02 15:04:05"))) templateBuff.WriteString(fmt.Sprintf(" \r\n ###### %s", time.Now().Format("2006/01/02 15:04:05")))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment