7001ca854c
Queuing Changes and Cfg Testing * staarting * staarting * startedpush * note * save * mocking * removederrs * fixtests * cleanuperrs * newenvsetup * preppingtests * queue * mmovetocfgpassunittests * sortoutconfig * passinginteg * deps * fixtests
35 lines
619 B
Go
35 lines
619 B
Go
package logger
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
"testing"
|
|
)
|
|
|
|
type TestLogger struct {
|
|
T *testing.T
|
|
Logs []map[string]interface{}
|
|
}
|
|
|
|
func (l *TestLogger) Handle(ctx context.Context, r slog.Record) error {
|
|
attrs := make(map[string]interface{})
|
|
r.Attrs(func(a slog.Attr) bool {
|
|
attrs[a.Key] = a.Value.Any()
|
|
return true
|
|
})
|
|
l.Logs = append(l.Logs, attrs)
|
|
return nil
|
|
}
|
|
|
|
func (l *TestLogger) Enabled(ctx context.Context, level slog.Level) bool {
|
|
return true
|
|
}
|
|
|
|
func (l *TestLogger) WithAttrs(attrs []slog.Attr) slog.Handler {
|
|
return l
|
|
}
|
|
|
|
func (l *TestLogger) WithGroup(name string) slog.Handler {
|
|
return l
|
|
}
|