func (l *Logger) Hooks(f ...func(Entry)) (logger *Logger) {
	return &Logger{
		config: l.config,
		writer: l.writer,
		hooks:  append(l.hooks, f...),
		with:   l.with,
	}
}
Hooks register functions to the current logger that are applied
after the entry is written. Hooks are cumulative and useful for
sending log data to log aggregation tools or capturing metrics.
package log
import (
	"io"
	"io/ioutil"
	"sync"
	"time"
)
const (
	ISO8601 = "2006-01-02T15:04:05.000Z0700"
	Unix = "unix"
	UnixMilli = "unix_milli"
	UnixNano = "unix_nano"
	entrySize = 512
)
var (
	encoderPool *sync.Pool
	DefaultConfig = Config{
		Level:          INFO,
		EnableCaller:   true,
		CallerSkip:     0,
		EnableTime:     true,
		TimeField:      "time",
		TimeFormat:     ISO8601,
		MessageField:   "message",
		EnableSampling: true,
		SamplingTick:   time.Second,
		SamplingStart:  100,
		SamplingFactor: 100,
	}
)
func init() {
	encoderPool = &sync.Pool{
		New: newEncoder,
	}
	for x := 0; x < 32; x++ {
		encoderPool.Put(newEncoder())
	}
}
func newEncoder() interface{} {
	return &encoder{data: make([]byte, 0, entrySize), index: -1}
}
type Config struct {
	Level          Level          
	EnableCaller   bool           
	CallerSkip     int            
	EnableTime     bool           
	TimeField      string         
	TimeFormat     string         
	MessageField   string         
	EnableSampling bool           
	SamplingTick   time.Duration  
	SamplingStart  int            
	SamplingFactor int            
}
type Logger struct {
	config  Config
	writer  io.Writer
	hooks   []func(Entry)
	with    []func(Entry)
	sampler *sampler
}
func New(writer io.Writer, config Config) (logger *Logger) {
	if writer == nil {
		writer = ioutil.Discard
	}
	logger = &Logger{}
	if config.EnableSampling {
		logger.sampler = newSampler(
			config.SamplingTick,
			config.SamplingStart,
			config.SamplingFactor)
	}
	logger.writer = writer
	logger.config = config
	return logger
}
func (l *Logger) With(f ...func(Entry)) (logger *Logger) {
	return &Logger{
		config: l.config,
		writer: l.writer,
		hooks:  l.hooks,
		with:   append(l.with, f...),
	}
}