Repository navigation
Use plain logging for subcommands and require subcommands first - #2196
Open
waldekmastykarz wants to merge 2 commits into
Open
waldekmastykarz wants to merge 2 commits into
waldekmastykarz wants to merge 2 commits into
Conversation
Subcommands such as 'devproxy api show' now print plain text without level labels; the decorated output is kept for the root command that monitors traffic. Options placed before a subcommand are now rejected, so the root command can be detected reliably from the first argument, even for subcommands contributed by plugins. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Configuration loading can preempt command-order errors and standalone validation when recursive options intervene, while logging thresholds can suppress usage diagnostics.
3 open issues
What changed in this PR
This PR separates subcommand output from Dev Proxy’s traffic-monitoring logs: subcommands use plain messages, while the root command retains decorated logging. It also introduces a subcommand-first argument rule.
Changes:
- Enables plain logging for subcommands and standalone plugin and validation commands.
- Adds ordering errors for options before subcommands and simplifies invocation detection.
- Updates tests for plain output and the new argument-ordering behavior.
| File | Description |
|---|---|
| DevProxy/Logging/ProxyConsoleFormatterOptions.cs | Adds the plain-output option. |
| DevProxy/Logging/ProxyConsoleFormatter.cs | Supports plain messages with short diagnostic prefixes. |
| DevProxy/Extensions/ILoggingBuilderExtensions.cs | Enables plain logging for subcommands. |
| DevProxy/Commands/PluginCommand.cs | Enables plain standalone plugin output. |
| DevProxy/Commands/DevProxyCommand.cs | Adds ordering checks and simplifies command detection. |
| DevProxy/Commands/ConfigCommand.cs | Enables plain standalone validation output. |
| DevProxy.Tests/ProxyConsoleFormatterTests.cs | Tests plain messages and diagnostic prefixes. |
| DevProxy.Tests/LoggingConfigurationTests.cs | Tests root versus subcommand formatting selection. |
| DevProxy.Tests/DevProxyConfigOptionsTests.cs | Removes coverage for leading environment options before stdio. |
| DevProxy.Tests/DevProxyCommandTests.cs | Tests subcommand-first detection and ordering errors. |
| DevProxy.Tests/ConfigValidateTests.cs | Updates validation cases for command-first arguments. |
Review effort: Balanced
- Allow recursive options between 'config' and 'validate' for standalone validation - Show the options-order error regardless of the configured log level Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Uses plain (undecorated) console output for all subcommands and keeps the decorated, level-labeled output only for the root command that monitors traffic.
Before, every line of e.g.
devproxy api showwas prefixed withinfo. Now:warning:/error:prefix.devproxy logsand detached log parsing are unaffected.Subcommands must come first
To reliably tell the root command from subcommands before plugins (which can contribute their own subcommands) are loaded, subcommands must now be the first argument. Options placed before a subcommand are rejected with exit code 2:
Recursive options (
--log-level,--output, ...) keep working after the subcommand. This simplifies the stdio/validate/plugin invocation detection, which no longer needs to skip leading option values.Changes
ProxyConsoleFormatterOptions.PlainOutput, enabled for subcommand logging,configand standalone plugin commandsDevProxyCommand.GetLeadingOptionsErrorenforces the subcommand-first rule (text and JSON output)IsStdioSubcommand,IsValidateInvocation,IsPluginCommandNotes
--envbeforestdio(undocumented) is no longer supporteddevproxy --detach api shownow fails with the new error instead of runningapi show