Files
query-orchestration/internal/serviceconfig/logger/testlogger.go
T
Michael McGuinness d91ef1832b Merged in feature/functestcov (pull request #84)
Function Test Coverage

* test

* scripts
2025-03-04 15:51:03 +00:00

35 lines
603 B
Go

package logger
import (
"context"
"log/slog"
"testing"
)
type TestLogger struct {
T *testing.T
Logs []map[string]any
}
func (l *TestLogger) Handle(ctx context.Context, r slog.Record) error {
attrs := make(map[string]any)
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
}