zrepl/internal/logger/testlogger.go
2024-10-18 19:21:17 +02:00

29 lines
426 B
Go

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),
}
}