7
"github.com/enescakir/emoji"
8
"github.com/fatih/color"
9
"github.com/nikwo/dogger/context"
13
DefaultTimeFormat = time.RFC3339
16
var dog = emoji.Sprint(":dog:")
18
var colorizers = map[string]func(...interface{}) string{
19
"trace": color.New(color.BgBlack).Add(color.FgHiWhite).SprintFunc(),
20
"debug": color.New(color.BgBlack).Add(color.FgHiBlue).SprintFunc(),
21
"info": color.New(color.BgBlack).Add(color.FgHiGreen).SprintFunc(),
22
"warn": color.New(color.BgBlack).Add(color.FgHiYellow).SprintFunc(),
23
"error": color.New(color.BgBlack).Add(color.FgHiRed).SprintFunc(),
24
"default": color.New(color.BgBlack).Add(color.FgWhite).SprintFunc(),
27
type Format interface {
28
FormatString(ctx context.LogContext) string
29
MatchVerboseColor(lvl string) string
32
type defaultFormat struct {
35
func (df *defaultFormat) FormatString(logContext context.LogContext) string {
39
df.MatchVerboseColor(logContext.GetLevel().String()),
40
logContext.GetTime().Format(DefaultTimeFormat),
41
logContext.GetCaller(),
45
func (df *defaultFormat) MatchVerboseColor(lvl string) string {
46
colorizer, exists := colorizers[lvl]
48
return colorizers["default"](lvl)
54
func DefaultFormatter() Format {
55
return &defaultFormat{}