1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package clinit
- import (
- elastic "gopkg.in/olivere/elastic.v5"
- )
- type ElasticErrorLog struct {
- }
- func (errLog *ElasticErrorLog) Printf(format string, v ...interface{}) {
- Error("", format, v...)
- }
- type ElasticInfoLog struct {
- }
- func (infoLog *ElasticInfoLog) Printf(format string, v ...interface{}) {
- Info("", format, v...)
- }
- type ElasticDebugLog struct {
- }
- func (debugLog *ElasticDebugLog) Printf(format string, v ...interface{}) {
- Debug("", format, v...)
- }
- var elasticClient *elastic.Client
- func InitElastic(addr string, sniff bool) {
- var err error
- elasticClient, err = elastic.NewClient(elastic.SetTraceLog(new(ElasticDebugLog)), elastic.SetInfoLog(new(ElasticInfoLog)),
- elastic.SetErrorLog(new(ElasticErrorLog)), elastic.SetSniff(sniff), elastic.SetURL(addr))
- if err != nil {
- panic(err)
- }
- }
- func GetElasticClient() *elastic.Client {
- return elasticClient
- }
|