func (el *esLogger) Flush() {
}
Flush is a empty method
package es
import (
	"encoding/json"
	"errors"
	"fmt"
	"net"
	"net/url"
	"time"
	"github.com/OwnLocal/goes"
	logs "github.com/kudoochui/kudos/log/beego"
)
func NewES() logs.Logger {
	cw := &esLogger{
		Level: logs.LevelDebug,
	}
	return cw
}
type esLogger struct {
	*goes.Client
	DSN   string `json:"dsn"`
	Level int    `json:"level"`
}
func (el *esLogger) Init(jsonconfig string) error {
	err := json.Unmarshal([]byte(jsonconfig), el)
	if err != nil {
		return err
	}
	if el.DSN == "" {
		return errors.New("empty dsn")
	} else if u, err := url.Parse(el.DSN); err != nil {
		return err
	} else if u.Path == "" {
		return errors.New("missing prefix")
	} else if host, port, err := net.SplitHostPort(u.Host); err != nil {
		return err
	} else {
		conn := goes.NewClient(host, port)
		el.Client = conn
	}
	return nil
}
func (el *esLogger) WriteMsg(when time.Time, msg string, level int) error {
	if level > el.Level {
		return nil
	}
	vals := make(map[string]interface{})
	vals["@timestamp"] = when.Format(time.RFC3339)
	vals["@msg"] = msg
	d := goes.Document{
		Index:  fmt.Sprintf("%04d.%02d.%02d", when.Year(), when.Month(), when.Day()),
		Type:   "logs",
		Fields: vals,
	}
	_, err := el.Index(d, nil)
	return err
}
func (el *esLogger) Destroy() {
}