func (f *textFormatter) encodeTimeWithFormat(e Entity) string {
	return e.Time().Format(f.timeFormat)
}
Encode the time with format of the log.
package logger
import (
	"bytes"
	"fmt"
	"regexp"
	"strconv"
	"strings"
	"github.com/edoger/zkits-logger/internal"
)
var formatRegexp = regexp.MustCompile(`{(name|time|level|message|caller|fields)(?:@?([^{}]*)?)?}`)
var defaultTextFormatter = MustNewTextFormatter("{name}:[{time}][{level@sc}] {message}{caller}{fields}", false)
var defaultQuoteTextFormatter = MustNewTextFormatter("{name}:[{time}][{level@sc}] {message}{caller}{fields}", true)
func DefaultTextFormatter() Formatter {
	return defaultTextFormatter
}
func DefaultQuoteTextFormatter() Formatter {
	return defaultQuoteTextFormatter
}
func NewTextFormatter(format string, quote bool) (Formatter, error) {
	sub := formatRegexp.FindAllStringSubmatch(format, -1)
	if len(sub) == 0 {
		return nil, fmt.Errorf("invalid text formatter format %q", format)
	}
	idx := formatRegexp.FindAllStringIndex(format, -1)
	f := &textFormatter{quote: quote, callerPrefix: " ", fieldsPrefix: " "}
	var parts []string
	var start int
	for i, j := 0, len(sub); i < j; i++ {
		key, args := sub[i][1], sub[i][2]
		switch key {
		case "name":
			f.encoders = append(f.encoders, f.encodeName)
		case "time":
			if args == "" {
				f.encoders = append(f.encoders, f.encodeTime)
			} else {
				f.timeFormat = args
				f.encoders = append(f.encoders, f.encodeTimeWithFormat)
			}
		case "level":
			switch args {
			case "cs", "sc":
				f.encoders = append(f.encoders, f.encodeShortCapitalLevel)
			case "s":
				f.encoders = append(f.encoders, f.encodeShortLevel)
			case "c":
				f.encoders = append(f.encoders, f.encodeCapitalLevel)
			default:
				f.encoders = append(f.encoders, f.encodeLevel)
			}
		case "message":
			f.encoders = append(f.encoders, f.encodeMessage)
		case "caller":
			f.encoders = append(f.encoders, f.encodeCaller)
			if args == "?" {
				f.callerPrefix = ""
			}
		case "fields":
			f.encoders = append(f.encoders, f.encodeFields)
			if args == "?" {
				f.fieldsPrefix = ""
			}
		}
		parts = append(parts, format[start:idx[i][0]])
		start = idx[i][1]
	}
	f.format = strings.Join(append(parts, format[start:]), "%s")
	return f, nil
}
func MustNewTextFormatter(format string, quote bool) Formatter {
	f, err := NewTextFormatter(format, quote)
	if err != nil {
		panic(err)
	}
	return f
}
type textFormatter struct {
	format       string
	quote        bool
	encoders     []func(Entity) string
	timeFormat   string
	callerPrefix string
	fieldsPrefix string
}
func (f *textFormatter) Format(e Entity, b *bytes.Buffer) (err error) {
	args := make([]interface{}, len(f.encoders))
	for i, j := 0, len(f.encoders); i < j; i++ {
		args[i] = f.encoders[i](e)
	}
	if f.quote {
		quoted := strconv.AppendQuote(nil, fmt.Sprintf(f.format, args...))
		quoted[len(quoted)-1] = '\n'
		_, err = b.Write(quoted[1:])
	} else {
		_, err = b.WriteString(fmt.Sprintf(f.format, args...) + "\n")
	}
	return
}
func (f *textFormatter) encodeName(e Entity) string {
	return e.Name()
}
func (f *textFormatter) encodeLevel(e Entity) string {
	return e.Level().String()
}
func (f *textFormatter) encodeShortCapitalLevel(e Entity) string {
	return e.Level().ShortCapitalString()
}
func (f *textFormatter) encodeShortLevel(e Entity) string {
	return e.Level().ShortString()
}
func (f *textFormatter) encodeCapitalLevel(e Entity) string {
	return e.Level().CapitalString()
}
func (f *textFormatter) encodeTime(e Entity) string {
	return e.TimeString()
}