Commit 154ec724 authored by 李世星's avatar 李世星

Merge branch 'lisx' into 'developer'

fix(修改日志打印): 202302131544

See merge request !19
parents 9c905f08 e25aa53c
Pipeline #16291 passed with stage
in 0 seconds
......@@ -2,7 +2,9 @@ package ding
import (
"bytes"
"encoding/json"
"fmt"
"reflect"
"time"
"github.com/y7ut/logtransfer/entity"
......@@ -75,6 +77,17 @@ func pluginNotice(msg interface{}) string {
templateBuff := bytes.NewBuffer([]byte{})
templateBuff.WriteString(fmt.Sprintf("# 服务通知 \r\n > 【节点】:%s", mateData.SourceAgent))
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", 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