diff --git a/go/vt/logutil/logger.go b/go/vt/logutil/logger.go index 47c3f124238..5667acaab9f 100644 --- a/go/vt/logutil/logger.go +++ b/go/vt/logutil/logger.go @@ -246,6 +246,12 @@ func (ml *MemoryLogger) Clear() { ml.mu.Unlock() } +func (ml *MemoryLogger) LogEvents() []*logutilpb.Event { + ml.mu.Lock() + defer ml.mu.Unlock() + return ml.Events +} + // LoggerWriter is an adapter that implements the io.Writer interface. type LoggerWriter struct { logger Logger diff --git a/go/vt/mysqlctl/blackbox/utils.go b/go/vt/mysqlctl/blackbox/utils.go index e4e3f11fb3c..c7d34ae3cf6 100644 --- a/go/vt/mysqlctl/blackbox/utils.go +++ b/go/vt/mysqlctl/blackbox/utils.go @@ -78,7 +78,7 @@ func GetStats(stats *backupstats.FakeStats) StatSummary { func AssertLogs(t *testing.T, expectedLogs []string, logger *logutil.MemoryLogger) { for _, log := range expectedLogs { - require.Truef(t, slices.ContainsFunc(logger.Events, func(event *logutilpb.Event) bool { + require.Truef(t, slices.ContainsFunc(logger.LogEvents(), func(event *logutilpb.Event) bool { return event.GetValue() == log }), "%s is missing from the logs", log) }