Skip to content

Fix obscured CLI failure messages during redirection#34

Open
google-labs-jules[bot] wants to merge 2 commits intomainfrom
fix-cli-redirection-logging-1337377593457569570
Open

Fix obscured CLI failure messages during redirection#34
google-labs-jules[bot] wants to merge 2 commits intomainfrom
fix-cli-redirection-logging-1337377593457569570

Conversation

@google-labs-jules
Copy link
Copy Markdown
Contributor

This change addresses the issue where CLI failures during redirection only show a simple "command failed" message by ensuring that all relevant internal logs and subprocess error details are mirrored to the error stream. Specifically, it modifies the central ConsoleLogger to duplicate its output to Console.Error when redirected and updates the CLI's subprocess runner to capture and selectively dump or mirror stdout to stderr when appropriate.


PR created automatically by Jules for task 1337377593457569570 started by @sator-imaging

- Modify `ConsoleLogger` to duplicate output to `Console.Error` when `Console.IsOutputRedirected` is true.
- Update `RunDotnetAsync` in `cli/Program.cs` to capture all subprocess stdout and dump it to `Console.Error` (and `Console.Out` for markdown) if a command fails and standard logging was suppressed.
- Proactively mirror subprocess stdout lines matching error/warning patterns to `Console.Error` when output is redirected.
- This ensures that build failures and test results are visible in CI logs even when stdout is redirected to files like `$GITHUB_STEP_SUMMARY`.
@google-labs-jules
Copy link
Copy Markdown
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

}

// always!!
message = message.Replace("\n", $"\n{new string(' ', SR.IndentationAdjustment)}", StringComparison.Ordinal);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Update to ConsoleLogger is no longer required.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Restored ConsoleLogger to its original state as requested.

}
};

if (requireStdOutLogging)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

If stdout is redirected, simply, write log to both stdout and stderr without any consideration.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated RunDotnetAsync to always log to both stdout and stderr when redirection is active, regardless of requireStdOutLogging or content (errors/warnings), and removed the redundant buffer dump for this case.

- Restore `ConsoleLogger.cs` to its original state.
- Update `cli/Program.cs` to simplify logging during redirection: when `Console.IsOutputRedirected` is true, all subprocess output is now immediately logged to both `Console.Out` and `Console.Error`, regardless of other conditions.
- Prevent redundant output buffering/dumping when redirection is already handling the logging.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant