修复es type错误问题
This commit is contained in:
		
							parent
							
								
									36a085eccb
								
							
						
					
					
						commit
						38247cf3c9
					
				
							
								
								
									
										18
									
								
								log_test.go
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								log_test.go
									
									
									
									
									
								
							@ -78,3 +78,21 @@ func TestNew(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	wg.Wait()
 | 
						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()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -89,7 +89,7 @@ func (el *esLogger) WriteMsg(when time.Time, msg string, level int, lable string
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	d := goes.Document{
 | 
						d := goes.Document{
 | 
				
			||||||
		Index:  fmt.Sprintf("%s-%04d.%02d.%02d", el.IndexName, when.Year(), when.Month(), when.Day()),
 | 
							Index:  fmt.Sprintf("%s-%04d.%02d.%02d", el.IndexName, when.Year(), when.Month(), when.Day()),
 | 
				
			||||||
		Type:   "logs",
 | 
							Type:   "_doc",
 | 
				
			||||||
		Fields: vals,
 | 
							Fields: vals,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	_, err := el.Index(d, nil)
 | 
						_, err := el.Index(d, nil)
 | 
				
			||||||
 | 
				
			|||||||
@ -281,7 +281,7 @@ func testFileRotate(t *testing.T, fn1, fn2 string, daily, hourly bool) {
 | 
				
			|||||||
		fw.hourlyOpenDate = fw.hourlyOpenTime.Day()
 | 
							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} {
 | 
						for _, file := range []string{fn1, fn2} {
 | 
				
			||||||
		_, err := os.Stat(file)
 | 
							_, err := os.Stat(file)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user