Skip to content

Consistently send messages to stderr when format is JSON. And display status message in more situations#14670

Merged
JamesNK merged 2 commits intorelease/13.2from
jamesnk/logs-display-get-message
Feb 26, 2026
Merged

Consistently send messages to stderr when format is JSON. And display status message in more situations#14670
JamesNK merged 2 commits intorelease/13.2from
jamesnk/logs-display-get-message

Conversation

@JamesNK
Copy link
Member

@JamesNK JamesNK commented Feb 25, 2026

Description

Consistently output non-JSON content to stderr when format is JSON. Set in BaseCommand to automatically set value.

Also display status message in more commands even when format is JSON because it's sent to stderr.
Also display status message when getting logs because it can take a while. Addresses #14646

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

@github-actions
Copy link
Contributor

github-actions bot commented Feb 25, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14670

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14670"

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #14646 by adding a "Getting logs..." status message to provide user feedback during log collection in the aspire logs command. The change improves user experience when the command takes time to collect logs, especially when no arguments are provided.

Changes:

  • Added "Getting logs..." localized status message displayed during log collection
  • Wrapped CollectLogsAsync calls with ShowStatusAsync to display the status message in both snapshot and watch modes
  • Added a development launch profile for easier testing of the logs command

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Aspire.Cli/Commands/LogsCommand.cs Wrapped log collection operations with status message display
src/Aspire.Cli/Resources/LogsCommandStrings.resx Added "GettingLogs" resource string
src/Aspire.Cli/Resources/LogsCommandStrings.Designer.cs Generated code for new resource string
src/Aspire.Cli/Resources/xlf/*.xlf Localization files updated with new string marked as state="new"
src/Aspire.Cli/Properties/launchSettings.json Added "logs" launch profile for development convenience
Files not reviewed (1)
  • src/Aspire.Cli/Resources/LogsCommandStrings.Designer.cs: Language not supported

@github-actions
Copy link
Contributor

github-actions bot commented Feb 25, 2026

🎬 CLI E2E Test Recordings

The following terminal recordings are available for commit d0ff1ac:

Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AgentInitCommand_WithMalformedMcpJson_ShowsErrorAndExitsNonZero ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
CreateAndDeployToDockerCompose ▶️ View Recording
CreateAndDeployToDockerComposeInteractive ▶️ View Recording
CreateAndPublishToKubernetes ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateEmptyAppHostProject ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateStartWaitAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording

📹 Recordings uploaded automatically from CI run #22420069544

@JamesNK JamesNK force-pushed the jamesnk/logs-display-get-message branch from 3fb284d to d9e2ac5 Compare February 25, 2026 06:16
@JamesNK JamesNK changed the title Display message for getting logs in aspire logs Consistently send messages to stderr when format is JSON. And display status message in more situations Feb 25, 2026
@JamesNK JamesNK force-pushed the jamesnk/logs-display-get-message branch from 124aab1 to 448d831 Compare February 25, 2026 22:15
/// <summary>
/// Checks whether this command has a --format option whose parsed value is <see cref="OutputFormat.Json"/>.
/// </summary>
private bool IsJsonFormatRequested(ParseResult parseResult)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just parseResult.GetValue("--format")?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only want to change the default console output if the command supports it, i.e. has a --format option. That means we need to get it, and since we have it then we can use it to get the value.

@mitchdenny
Copy link
Member

I think it would be good to have an E2E CLI test for all of these JSON outputting commands. Something that basically runs the CLI through its paces and does --format json > output-step1.json and then verifies that the output file is parsable. This would act as a safeguard.

Copy link
Member

@mitchdenny mitchdenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve pending some E2E CLI tests.

@JamesNK JamesNK merged commit 7dc9a6a into release/13.2 Feb 26, 2026
676 of 679 checks passed
@JamesNK JamesNK deleted the jamesnk/logs-display-get-message branch February 26, 2026 00:52
@dotnet-policy-service dotnet-policy-service bot added this to the 13.2 milestone Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants