mirror of
https://gitee.ltd/lxh/logger.git
synced 2026-04-02 14:17:23 +08:00
✨ 支持初始化的时候从环境变量读取配置信息
This commit is contained in:
7
loki.go
7
loki.go
@@ -69,14 +69,13 @@ func (c lokiWriter) Write(p []byte) (int, error) {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
label := model.LabelSet{"job": model.LabelValue(config.LokiName)}
|
||||
label["source"] = model.LabelValue(config.LokiName)
|
||||
label := model.LabelSet{"job": model.LabelValue(config.LokiJob)}
|
||||
label["source"] = model.LabelValue(config.LokiSource)
|
||||
label["level"] = model.LabelValue(li.Level)
|
||||
label["caller"] = model.LabelValue(li.Caller)
|
||||
// 异步推送消息到服务器
|
||||
go func() {
|
||||
err = lokiClient.Handle(label, time.Now().Local(), li.Msg)
|
||||
if err != nil {
|
||||
if err = lokiClient.Handle(label, time.Now().Local(), li.Msg); err != nil {
|
||||
fmt.Printf("日志推送到Loki失败: %v\n", err.Error())
|
||||
}
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user