-
Notifications
You must be signed in to change notification settings - Fork 79
Add --log-for human|machine flag for LLM/agent-friendly output #1508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
…y else Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
|
@copilot update the branch with rebase and resolve conflicts ensuring all functionality is intact |
I'm unable to perform a rebase as my environment doesn't support force push operations required for rebase. However, I've verified the branch has been merged with main (commit 1859143), the build succeeds, and all Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this 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 pull request adds a --log-for flag to enable machine-readable JSON Lines output for LLMs and coding agents, addressing the challenge of parsing ANSI-decorated, human-friendly console output.
Changes:
- Added LogFor enum (Human|Machine) in abstractions with EnumMember attributes for JSON serialization
- Implemented MachineConsoleFormatter that outputs structured JSON Lines with semantic types, correlation IDs, and ISO 8601 timestamps
- Added CLI option
--log-forand configuration propertylogForwith validation
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| schemas/v2.1.0/rc.schema.json | Adds logFor property with human/machine enum values to the configuration schema |
| DevProxy/Proxy/ProxyConfiguration.cs | Adds LogFor property with JSON converter to configuration class |
| DevProxy/Logging/ProxyConsoleFormatterOptions.cs | Adds LogFor property to formatter options |
| DevProxy/Logging/MachineConsoleFormatter.cs | New formatter that outputs JSON Lines format with semantic message types and full context |
| DevProxy/Extensions/ILoggingBuilderExtensions.cs | Updates logging configuration to select formatter based on LogFor setting |
| DevProxy/Commands/DevProxyConfigOptions.cs | Adds LogFor option parsing with custom parser and validation |
| DevProxy/Commands/DevProxyCommand.cs | Registers --log-for as a global recursive CLI option with enum validation |
| DevProxy.Abstractions/Proxy/IProxyConfiguration.cs | Adds LogFor enum definition and property to interface |
| public string? IPAddress { get; set; } = "127.0.0.1"; | ||
| public bool InstallCert { get; set; } = true; | ||
| [JsonConverter(typeof(JsonStringEnumConverter))] | ||
| public LogFor LogFor { get; set; } = LogFor.Human; |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The LogFor property in ProxyConfiguration is settable (public setter), but in IProxyConfiguration it's defined as read-only (only a getter). This inconsistency could lead to issues where the configuration can be changed through ProxyConfiguration but not through the interface contract. Consider making LogFor read-only in ProxyConfiguration by removing the set accessor, or if it needs to be settable, add a setter to the IProxyConfiguration interface.
| using DevProxy.Abstractions.Proxy; | ||
| using Microsoft.Extensions.Logging.Console; | ||
|
|
||
| namespace DevProxy.Logging; | ||
|
|
||
| sealed class ProxyConsoleFormatterOptions : ConsoleFormatterOptions | ||
| { | ||
| public LogFor LogFor { get; set; } = LogFor.Human; | ||
|
|
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ProxyConsoleFormatterOptions class has a LogFor property that is set but never used in the ProxyConsoleFormatter class. This suggests that the LogFor property may be unnecessary in ProxyConsoleFormatterOptions, or the ProxyConsoleFormatter should be using it. Given that the machine mode is selected by choosing a different formatter (MachineConsoleFormatter), this property appears to be dead code in the context of ProxyConsoleFormatter.
| using DevProxy.Abstractions.Proxy; | |
| using Microsoft.Extensions.Logging.Console; | |
| namespace DevProxy.Logging; | |
| sealed class ProxyConsoleFormatterOptions : ConsoleFormatterOptions | |
| { | |
| public LogFor LogFor { get; set; } = LogFor.Human; | |
| using Microsoft.Extensions.Logging.Console; | |
| namespace DevProxy.Logging; | |
| sealed class ProxyConsoleFormatterOptions : ConsoleFormatterOptions | |
| { |
Current console output uses ANSI codes, Unicode box characters, and terse labels that waste tokens and are hard for LLMs/agents to parse programmatically.
Changes
LogForenum (Human|Machine) inDevProxy.Abstractions--log-forCLI option as a global/recursive option with validationlogForconfig property indevproxyrc.json(CLI takes precedence)MachineConsoleFormatteroutputs JSON Lines with:request,response,warning,error,mock,chaos)requestId)logForinrc.schema.jsonUsage
{"logFor": "machine"}Output
{"type":"log","level":"info","message":"Dev Proxy listening on 127.0.0.1:8000...","category":"ProxyEngine","timestamp":"2026-01-19T12:05:44.766Z"} {"type":"request","method":"GET","url":"https://api.example.com/users","requestId":"1","timestamp":"2026-01-19T10:30:00.000Z"} {"type":"chaos","plugin":"RateLimitingPlugin","message":"TooManyRequests","requestId":"1","timestamp":"2026-01-19T10:30:00.050Z"}Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
aka.ms/home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy --help(dns block)/home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy --log-for machine --log-level information --no-first-run nsion(dns block)/home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy --log-for human --log-level information --no-first-run(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.