From ff5ac3adf409e746376e5b14e10a4e105869bda7 Mon Sep 17 00:00:00 2001 From: IamCathal Date: Wed, 19 Aug 2020 16:13:42 +0100 Subject: [PATCH] Update signature of WriteMsg in es.go --- pkg/logs/alils/alils.go | 8 ++++---- pkg/logs/es/es.go | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/logs/alils/alils.go b/pkg/logs/alils/alils.go index 1bd6b653..6c1464f2 100644 --- a/pkg/logs/alils/alils.go +++ b/pkg/logs/alils/alils.go @@ -113,7 +113,7 @@ func (c *aliLSWriter) WriteMsg(lm *logs.LogMsg) error { if c.withMap { // Topic,LogGroup - strs := strings.SplitN(msg, Delimiter, 2) + strs := strings.SplitN(lm.Msg, Delimiter, 2) if len(strs) == 2 { pos := strings.LastIndex(strs[0], " ") topic = strs[0][pos+1 : len(strs[0])] @@ -123,11 +123,11 @@ func (c *aliLSWriter) WriteMsg(lm *logs.LogMsg) error { // send to empty Topic if lg == nil { - content = msg + content = lm.Msg lg = c.group[0] } } else { - content = msg + content = lm.Msg lg = c.group[0] } @@ -137,7 +137,7 @@ func (c *aliLSWriter) WriteMsg(lm *logs.LogMsg) error { } l := &Log{ - Time: proto.Uint32(uint32(when.Unix())), + Time: proto.Uint32(uint32(lm.When.Unix())), Contents: []*LogContent{ c1, }, diff --git a/pkg/logs/es/es.go b/pkg/logs/es/es.go index 7542b577..5c91b2ed 100644 --- a/pkg/logs/es/es.go +++ b/pkg/logs/es/es.go @@ -60,14 +60,14 @@ func (el *esLogger) Init(jsonconfig string) error { } // WriteMsg writes the msg and level into es -func (el *esLogger) WriteMsg(when time.Time, msg string, level int) error { - if level > el.Level { +func (el *esLogger) WriteMsg(lm *logs.LogMsg) error { + if lm.Level > el.Level { return nil } idx := LogDocument{ - Timestamp: when.Format(time.RFC3339), - Msg: msg, + Timestamp: lm.When.Format(time.RFC3339), + Msg: lm.Msg, } body, err := json.Marshal(idx) @@ -75,7 +75,7 @@ func (el *esLogger) WriteMsg(when time.Time, msg string, level int) error { return err } req := esapi.IndexRequest{ - Index: fmt.Sprintf("%04d.%02d.%02d", when.Year(), when.Month(), when.Day()), + Index: fmt.Sprintf("%04d.%02d.%02d", lm.When.Year(), lm.When.Month(), lm.When.Day()), DocumentType: "logs", Body: strings.NewReader(string(body)), }