MailHog/vendor/github.com/ian-kent/go-log/appenders/console.go
2016-08-10 07:56:48 +01:00

31 lines
585 B
Go

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
}