|
@@ -7,29 +7,30 @@ import (
|
|
|
"github.com/olivere/elastic/v7"
|
|
|
"hongze/hongze_cygx/models"
|
|
|
"hongze/hongze_cygx/utils"
|
|
|
- "log"
|
|
|
- "os"
|
|
|
"sort"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
|
func NewClient() (client *elastic.Client, err error) {
|
|
|
- errorlog := log.New(os.Stdout, "APP", log.LstdFlags)
|
|
|
- file := ""
|
|
|
- if utils.RunMode == "release" {
|
|
|
- //file = `/data/rdlucklog/hongze_cygx/eslog.log`
|
|
|
- file = `./rdlucklog/eslog.log`
|
|
|
- } else {
|
|
|
- file = `./rdlucklog/eslog.log`
|
|
|
- }
|
|
|
- logFile, _ := os.OpenFile(file, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0766)
|
|
|
+ //errorlog := log.New(os.Stdout, "APP", log.LstdFlags)
|
|
|
+ //file := ""
|
|
|
+ //if utils.RunMode == "release" {
|
|
|
+ // //file = `/data/rdlucklog/hongze_cygx/eslog.log`
|
|
|
+ // file = `./rdlucklog/eslog.log`
|
|
|
+ //} else {
|
|
|
+ // file = `./rdlucklog/eslog.log`
|
|
|
+ //}
|
|
|
+ //logFile, _ := os.OpenFile(file, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0766)
|
|
|
+ //client, err = elastic.NewClient(
|
|
|
+ // elastic.SetURL(ES_URL),
|
|
|
+ // elastic.SetBasicAuth(ES_USERNAME, ES_PASSWORD),
|
|
|
+ // elastic.SetTraceLog(log.New(logFile, "ES-TRACE: ", 0)),
|
|
|
+ // elastic.SetSniff(false), elastic.SetErrorLog(errorlog))
|
|
|
client, err = elastic.NewClient(
|
|
|
elastic.SetURL(ES_URL),
|
|
|
elastic.SetBasicAuth(ES_USERNAME, ES_PASSWORD),
|
|
|
- elastic.SetTraceLog(log.New(logFile, "ES-TRACE: ", 0)),
|
|
|
- elastic.SetSniff(false), elastic.SetErrorLog(errorlog))
|
|
|
- defer logFile.Close()
|
|
|
+ elastic.SetSniff(false))
|
|
|
return
|
|
|
}
|
|
|
|