zrepl/logger/testlogger.go

29 lines
426 B
Go
Raw Normal View History

2018-08-29 19:00:45 +02:00
package logger
import (
"testing"
)
type testLogger struct {
Logger
}
type testingLoggerOutlet struct {
t *testing.T
}
func (o testingLoggerOutlet) WriteEntry(entry Entry) error {
o.t.Logf("%#v", entry)
return nil
}
var _ Logger = testLogger{}
func NewTestLogger(t *testing.T) Logger {
outlets := NewOutlets()
outlets.Add(&testingLoggerOutlet{t}, Debug)
return &testLogger{
Logger: NewLogger(outlets, 0),
}
}