mirror of
https://gitlab.com/ric_harvey/MailHog.git
synced 2024-11-25 07:14:04 +00:00
31 lines
585 B
Go
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
|
|
}
|