Exemplo n.º 1
0
func newColorLogger(w io.Writer) log.Logger {
	return term.NewColorLogger(w, log.NewLogfmtLogger,
		func(keyvals ...interface{}) term.FgBgColor {
			if keyvals[0] == "a" {
				return term.FgBgColor{Fg: term.Green, Bg: term.White}
			}
			return term.FgBgColor{}
		})
}
Exemplo n.º 2
0
func newColorLogger(t testing.TB, w io.Writer) log.Logger {
	return term.NewColorLogger(log.NewLogfmtLogger(w),
		"a", term.ColorOption{Value: func(_ interface{}) term.FgBgColor {
			return term.FgBgColor{Fg: term.Green, Bg: term.Default}
		}},
		"err", term.ColorOption{Value: func(err interface{}) term.FgBgColor {
			if err == nil {
				return term.FgBgColor{}
			}
			return term.FgBgColor{Fg: term.White, Bg: term.Red}
		}},
	)
}