diff --git a/log_test.go b/log_test.go index 350a9ab..b05fded 100644 --- a/log_test.go +++ b/log_test.go @@ -78,3 +78,21 @@ func TestNew(t *testing.T) { wg.Wait() } + +func TestGetEs(t *testing.T) { + wg := sync.WaitGroup{} + for i := 0; i < 10; i++ { + wg.Add(1) + go func(i int) { + GetEs("ok").Debug("%d", i) + time.Sleep(time.Second * 10) + wg.Done() + }(i) + } + + for i := 0; i < 10; i++ { + GetEs("ok").Debug("aaaaaa%d", i) + } + + wg.Wait() +} diff --git a/logs/es/es.go b/logs/es/es.go index d017282..abcc255 100644 --- a/logs/es/es.go +++ b/logs/es/es.go @@ -89,7 +89,7 @@ func (el *esLogger) WriteMsg(when time.Time, msg string, level int, lable string d := goes.Document{ Index: fmt.Sprintf("%s-%04d.%02d.%02d", el.IndexName, when.Year(), when.Month(), when.Day()), - Type: "logs", + Type: "_doc", Fields: vals, } _, err := el.Index(d, nil) diff --git a/logs/file_test.go b/logs/file_test.go index 385eac4..dd02f91 100644 --- a/logs/file_test.go +++ b/logs/file_test.go @@ -281,7 +281,7 @@ func testFileRotate(t *testing.T, fn1, fn2 string, daily, hourly bool) { fw.hourlyOpenDate = fw.hourlyOpenTime.Day() } - fw.WriteMsg(time.Now(), "this is a msg for test", LevelDebug) + fw.WriteMsg(time.Now(), "this is a msg for test", LevelDebug, "", "dev") for _, file := range []string{fn1, fn2} { _, err := os.Stat(file)