func (e Entry) WithLevel(l Level) Entry {
	e.Level = l
	return e
}
WithLevel sets the Entry level.
package metrics
import (
	"fmt"
	"strings"
	"time"
)
const (
	RedAlertLvl    Level = iota  
	YellowAlertLvl               
	ErrorLvl                     
	InfoLvl                      
)
type Level int
func GetLevel(lvl string) Level {
	switch strings.ToLower(lvl) {
	case "redalert", "redalartlvl":
		return RedAlertLvl
	case "yellowalert", "yellowalertlvl":
		return YellowAlertLvl
	case "error", "errorlvl":
		return ErrorLvl
	case "info", "infolvl":
		return InfoLvl
	}
	return -1
}
func (l Level) String() string {
	switch l {
	case RedAlertLvl:
		return "REDALERT"
	case YellowAlertLvl:
		return "YELLOWALERT"
	case ErrorLvl:
		return "ERROR"
	case InfoLvl:
		return "INFO"
	}
	return "UNKNOWN"
}
type EntryMod func(*Entry)
func Partial(mods ...EntryMod) EntryMod {
	if len(mods) == 1 {
		return mods[0]
	}
	return func(en *Entry) {
		for _, mod := range mods {
			mod(en)
		}
	}
}
func Apply(en *Entry, mods ...EntryMod) {
	for _, mod := range mods {
		mod(en)
	}
}
type Timelapse struct {
	Message string    `json:"message"`
	Time    time.Time `json:"time"`
	Field   Field     `json:"fields"`
}
func WithTimelapse(message string, f Field) EntryMod {
	return func(en *Entry) {
		en.Timelapse = append(en.Timelapse, Timelapse{
			Field:   f,
			Message: message,
			Time:    time.Now(),
		})
	}
}
func YellowAlert(err error, message string, m ...interface{}) EntryMod {
	return Partial(withMessageAt(4, YellowAlertLvl, message, m...), func(en *Entry) {
		en.Field["error"] = err
	})
}
func RedAlert(err error, message string, m ...interface{}) EntryMod {
	return Partial(withMessageAt(4, RedAlertLvl, message, m...), func(en *Entry) {
		en.Field["error"] = err
	})
}
func Errorf(message string, m ...interface{}) EntryMod {
	err := fmt.Errorf(message, m...)
	return Partial(withMessageAt(4, ErrorLvl, err.Error()), func(en *Entry) {
		en.Field["error"] = err
	})
}
func Error(err error) EntryMod {
	return Partial(withMessageAt(4, ErrorLvl, err.Error()), func(en *Entry) {
		en.Field["error"] = err
	})
}
func Info(message string, m ...interface{}) EntryMod {
	return withMessageAt(4, InfoLvl, message, m...)
}
func Message(message string, m ...interface{}) EntryMod {
	return func(en *Entry) {
		en.Message = fmt.Sprintf(message, m...)
	}
}
func WithMessage(level Level, message string, m ...interface{}) EntryMod {
	return withMessageAt(4, level, message, m...)
}
func withMessageAt(depth int, level Level, message string, m ...interface{}) EntryMod {
	function, file, line := getFunctionName(depth)
	return func(e *Entry) {
		e.Level = level
		e.Field = make(Field)
		e.Time = time.Now()
		e.Function, e.File, e.Line = function, file, line
		if len(m) == 0 {
			e.Message = message
			return
		}
		e.Message = fmt.Sprintf(message, m...)
	}
}
func WithTrace(t *Trace) EntryMod {
	return func(en *Entry) {
		en.Trace = t
	}
}
func WithField(filter interface{}) EntryMod {
	return func(en *Entry) {
		en.Filter = filter
	}
}
func WithID(id string) EntryMod {
	return func(en *Entry) {
		en.ID = id
	}
}
func With(key string, value interface{}) EntryMod {
	return func(en *Entry) {
		if en.Field == nil {
			en.Field = make(Field)
		}
		en.Field[key] = value
	}
}
func WithFields(f Field) EntryMod {
	return func(en *Entry) {
		if en.Field == nil {
			en.Field = make(Field)
		}
		for k, v := range f {
			en.Field[k] = v
		}
	}
}
type Entry struct {
	ID        string      `json:"id"`
	Function  string      `json:"function"`
	File      string      `json:"file"`
	Line      int         `json:"line"`
	Level     Level       `json:"level"`
	Field     Field       `json:"fields"`
	Time      time.Time   `json:"time"`
	Message   string      `json:"message"`
	Filter    interface{} `json:"filter"`
	Trace     *Trace      `json:"trace"`
	Timelapse []Timelapse `json:"timelapse"`
}
func (e Entry) WithMessage(message string, m ...interface{}) Entry {
	if len(m) == 0 {
		e.Message = message
		return e
	}
	e.Message = fmt.Sprintf(message, m...)
	return e
}
func (e Entry) WithID(id string) Entry {
	e.ID = id
	return e
}