MailHog/vendor/github.com/ian-kent/go-log/appenders/console.go

32 lines
585 B
Go
Raw Normal View History

2016-08-10 06:56:48 +00:00
package appenders
import (
"fmt"
"github.com/ian-kent/go-log/layout"
"github.com/ian-kent/go-log/levels"
)
type consoleAppender struct {
Appender
layout layout.Layout
}
func Console() *consoleAppender {
a := &consoleAppender{
layout: layout.Default(),
}
return a
}
func (a *consoleAppender) Write(level levels.LogLevel, message string, args ...interface{}) {
fmt.Println(a.Layout().Format(level, message, args...))
}
func (a *consoleAppender) Layout() layout.Layout {
return a.layout
}
func (a *consoleAppender) SetLayout(layout layout.Layout) {
a.layout = layout
}