mirror of
https://gitlab.com/ric_harvey/MailHog.git
synced 2024-12-18 10:27:16 +00:00
32 lines
585 B
Go
32 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
|
||
|
}
|