diff --git a/src/Aspire.Dashboard/Components/Pages/ConsoleLogs.razor.cs b/src/Aspire.Dashboard/Components/Pages/ConsoleLogs.razor.cs index db0f679b859..4487cbf3fbc 100644 --- a/src/Aspire.Dashboard/Components/Pages/ConsoleLogs.razor.cs +++ b/src/Aspire.Dashboard/Components/Pages/ConsoleLogs.razor.cs @@ -477,7 +477,10 @@ private void LoadLogs(ConsoleLogsSubscription newConsoleLogsSubscription) { lock (_updateLogsLock) { - foreach (var priorPause in PauseManager.ConsoleLogPauseIntervals) + var pauseIntervals = PauseManager.ConsoleLogPauseIntervals; + Logger.LogDebug("Adding {PauseIntervalsCount} pause intervals on initial logs load.", pauseIntervals.Length); + + foreach (var priorPause in pauseIntervals) { _logEntries.InsertSorted(LogEntry.CreatePause(priorPause.Start, priorPause.End)); } @@ -660,6 +663,8 @@ private async Task ClearConsoleLogs(ApplicationKey? key) private void OnPausedChanged(bool isPaused) { + Logger.LogDebug("Console logs paused new value: {IsPausedNewValue}", isPaused); + var timestamp = DateTime.UtcNow; PauseManager.SetConsoleLogsPaused(isPaused, timestamp); @@ -669,12 +674,15 @@ private void OnPausedChanged(bool isPaused) { if (isPaused) { + Logger.LogDebug("Inserting new pause log entry starting at {StartTimestamp}.", timestamp); _logEntries.InsertSorted(LogEntry.CreatePause(timestamp)); } else { var pause = _logEntries.GetEntries().Last().Pause; Debug.Assert(pause is not null); + + Logger.LogDebug("Updating pause log entry starting at {StartTimestamp} with end of {EndTimestamp}.", pause.StartTime, timestamp); pause.EndTime = timestamp; } } diff --git a/tests/Aspire.Dashboard.Components.Tests/Pages/ConsoleLogsTests.cs b/tests/Aspire.Dashboard.Components.Tests/Pages/ConsoleLogsTests.cs index 40e487c15a7..cf5ca59963d 100644 --- a/tests/Aspire.Dashboard.Components.Tests/Pages/ConsoleLogsTests.cs +++ b/tests/Aspire.Dashboard.Components.Tests/Pages/ConsoleLogsTests.cs @@ -450,8 +450,9 @@ public void PauseResumeButton_TogglePauseResume_LogsPausedAndResumed() cut.WaitForState(() => instance.PageViewModel.SelectedResource == testResource); logger.LogInformation("Pause logs."); - var pauseResumeButton = cut.FindComponent(); - pauseResumeButton.Find("fluent-button").Click(); + var pauseResumeButton = cut.FindComponent().WaitForElement("fluent-button"); + pauseResumeButton.Click(); + cut.WaitForAssertion(() => Assert.True(pauseManager.ConsoleLogsPaused)); logger.LogInformation("Wait for pause log."); var pauseConsoleLogLine = cut.WaitForElement(".log-pause"); @@ -477,8 +478,8 @@ public void PauseResumeButton_TogglePauseResume_LogsPausedAndResumed() // - the pause line has been replaced with pause details // - the log viewer shows the new log // - the log viewer does not show the discarded log - pauseResumeButton.Find("fluent-button").Click(); - cut.WaitForAssertion(() => Assert.False(Services.GetRequiredService().ConsoleLogsPaused)); + pauseResumeButton.Click(); + cut.WaitForAssertion(() => Assert.False(pauseManager.ConsoleLogsPaused)); logger.LogInformation("Write a new log."); var resumeContent = $"{DateTime.UtcNow:yyyy-MM-ddTHH:mm:ss.fffK} Log after resume";