Files
query-orchestration/internal/serviceconfig/logger/testlogger.go
T
Michael McGuinness 7001ca854c Merged in feature/docinitialisation (pull request #41)
Queuing Changes and Cfg Testing

* staarting

* staarting

* startedpush

* note

* save

* mocking

* removederrs

* fixtests

* cleanuperrs

* newenvsetup

* preppingtests

* queue

* mmovetocfgpassunittests

* sortoutconfig

* passinginteg

* deps

* fixtests
2025-02-03 17:30:50 +00:00

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
}