package esLogUtil import ( "testing" "time" ) func TestWrite(t *testing.T) { Start("http://10.1.0.86:9200", "dzg_gs_log_gmc2", 20008) for i := 0; i < 10000; i++ { InfoLog("ES在线日志测试") WarnLog("ES在线日志测试") DebugLog("ES在线日志测试") ErrorLog("ES在线日志测试") FatalLog("ES在线日志测试") } Stop() } func BenchmarkWrite(b *testing.B) { Start("http://106.52.100.147:14001", "20008_gs_log", 20008) b.ResetTimer() for i := 0; i < b.N; i++ { InfoLog("ES在线日志测试%d", i) WarnLog("ES在线日志测试%d", i) DebugLog("ES在线日志测试%d", i) ErrorLog("ES在线日志测试%d", i) FatalLog("ES在线日志测试%d", i) } b.StopTimer() time.Sleep(30 * time.Second) Stop() }