mirror of
https://gitee.ltd/lxh/logger.git
synced 2025-10-23 23:06:19 +08:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
be64023660 | |||
|
aff875eb11 | ||
c9ca2b3858 | |||
|
869dedc580 |
6
loki.go
6
loki.go
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/prometheus/common/model"
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -76,11 +75,7 @@ func (c lokiWriter) Write(p []byte) (int, error) {
|
||||
label["level"] = model.LabelValue(li.Level)
|
||||
label["caller"] = model.LabelValue(li.Caller)
|
||||
|
||||
// 异步推送消息到服务器
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
_ = ants.Submit(func() {
|
||||
defer wg.Done()
|
||||
t, e := time.ParseInLocation("2006-01-02 15:04:05.000", li.Ts, time.Local)
|
||||
if e != nil {
|
||||
t = time.Now().Local()
|
||||
@@ -89,7 +84,6 @@ func (c lokiWriter) Write(p []byte) (int, error) {
|
||||
fmt.Printf("日志推送到Loki失败: %v\n", err.Error())
|
||||
}
|
||||
})
|
||||
wg.Wait()
|
||||
|
||||
return 0, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user