Commit 374164fd authored by 谢宇轩's avatar 谢宇轩 😅

修改时区的bug

parent 2b7c019b
......@@ -8,6 +8,10 @@ import (
"time"
)
const (
Location = "Asia/Shanghai"
)
type Formater func(string, string) (Matedata, error)
// service错误日志的处理
......@@ -23,7 +27,8 @@ func FormatServiceWfLog(sourceKey string, message string) (Matedata, error) {
mateItem.Topic = sourceKey
mateItem.Level = message[:levelIndex]
message = message[levelIndex:]
loc, _ := time.LoadLocation("Local")
loc, _ := time.LoadLocation(Location)
logTime, _ := time.ParseInLocation(": 06-01-02 15:04:05 ", message[:strings.Index(message, "[")], loc)
mateItem.create = logTime
keyword := serviceWfLogKeyWord
......@@ -65,7 +70,7 @@ func DefaultLog(sourceKey string, message string) (Matedata, error) {
return result, nil
}
// Json 格式的错误日志处理
// 标志Json 格式的错误日志处理
func DefaultJsonLog(sourceKey string, message string) (Matedata, error) {
vMateItem := MatePool.Get()
......@@ -82,3 +87,5 @@ func DefaultJsonLog(sourceKey string, message string) (Matedata, error) {
MatePool.Put(vMateItem)
return result, nil
}
func
\ No newline at end of file
......@@ -36,7 +36,7 @@ func (m *Matedata) reset() {
func HandleMessage(m *Matedata) {
messages <- m
}
func CloseMessageChan() {
close(messages)
}
......@@ -90,20 +90,31 @@ func MatedateSender(ctx context.Context) {
var mateDatesItems []*Matedata
var mu sync.Mutex
autoTicker := time.NewTicker(10 * time.Second)
for {
select {
case m := <-messages:
mu.Lock()
mateDatesItems = append(mateDatesItems, m)
currentItems := mateDatesItems
mu.Unlock()
if len(currentItems) > 10 {
mateDatesItems = mateDatesItems[:0]
mu.Unlock()
wp.Serve(currentItems)
mu.Lock()
}else{
mu.Unlock()
}
case <-autoTicker.C:
mu.Lock()
currentItems := mateDatesItems
if len(currentItems) > 0 {
mateDatesItems = mateDatesItems[:0]
mu.Unlock()
wp.Serve(currentItems)
}else{
mu.Unlock()
}
case <-ctx.Done():
......
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