Compare commits

...

3 Commits

Author SHA1 Message Date
8b94a0d256 修改es账号密码 2022-10-31 15:41:38 +08:00
38247cf3c9 修复es type错误问题 2022-10-28 17:18:50 +08:00
36a085eccb 修改es服务端地址 2022-10-28 16:03:47 +08:00
4 changed files with 24 additions and 6 deletions

View File

@ -80,14 +80,14 @@ func GenAliConfig(level Level) *AliLSConfig {
} }
func GenEsConfig(level Level) *EsConfig { func GenEsConfig(level Level) *EsConfig {
dsn := "http://es-cn-0pp1mm3hq000dnbh4.public.elasticsearch.aliyuncs.com:9200/" dsn := "http://es-cn-tl32xlfmu00015h34.public.elasticsearch.aliyuncs.com:9200/"
if os.Getenv(envkey) == "prod" || os.Getenv(envkey) == "" || os.Getenv(envkey) == "gray" { if os.Getenv(envkey) == "prod" || os.Getenv(envkey) == "" || os.Getenv(envkey) == "gray" {
dsn = "http://es-cn-0pp1mm3hq000dnbh4.elasticsearch.aliyuncs.com:9200/" dsn = "http://es-cn-tl32xlfmu00015h34.elasticsearch.aliyuncs.com:9200/"
} }
c := &EsConfig{ c := &EsConfig{
Username: "elastic", Username: "kaifa_api",
Password: "Hellogaore@", Password: "2quYX3bTeahO",
Dsn: dsn, Dsn: dsn,
Level: level, Level: level,
Index: os.Getenv("GRLOG_APP_NAME"), Index: os.Getenv("GRLOG_APP_NAME"),

View File

@ -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()
}

View File

@ -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)

View File

@ -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)