Commit dc02ba53 authored by 谢宇轩's avatar 谢宇轩 😅

修改时区为UTC

parent b20faf95
......@@ -28,9 +28,9 @@ func FormatServiceWfLog(sourceKey string, message string) (Matedata, error) {
mateItem.Level = message[:levelIndex]
message = message[levelIndex:]
loc, err := time.LoadLocation(Location)
loc, err := time.LoadLocation("UTC")
if err != nil {
loc = time.FixedZone("CST", 8*3600)
loc = time.FixedZone("UTC", 0)
}
logTime, _ := time.ParseInLocation(": 06-01-02 15:04:05 ", message[:strings.Index(message, "[")], loc)
mateItem.create = logTime
......
......@@ -3,18 +3,34 @@ package plugin
import (
"fmt"
"log"
"time"
"github.com/y7ut/logtransfer/entity"
)
const (
Location = "Asia/Shanghai"
)
// 打印插件
type Dump Plugin
func (dump *Dump) HandleFunc(m *entity.Matedata) error {
log.Println("DUMP:")
for k, v := range (*m).Data {
if k == "timestamp" {
loc, err := time.LoadLocation(Location)
if err != nil {
loc = time.FixedZone("CST", 8*3600)
}
v, err = time.ParseInLocation("2006-01-02 15:04:05 ", fmt.Sprintf("%s", v), loc)
if err != nil {
continue
}
}
fmt.Printf("%s : %s\n", k, v)
}
fmt.Println("------------")
return nil
}
......
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