Skip to content

Commit d849d8c

Browse files
Rename MachineConsoleFormatter to JsonConsoleFormatter to reflect json output mode
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
1 parent 85f57c8 commit d849d8c

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

DevProxy/Extensions/ILoggingBuilderExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static ILoggingBuilder ConfigureDevProxyLogging(
5858

5959
// Select the appropriate formatter based on output setting
6060
var formatterName = configuredOutput == OutputFormat.Json
61-
? MachineConsoleFormatter.FormatterName
61+
? JsonConsoleFormatter.FormatterName
6262
: ProxyConsoleFormatter.DefaultCategoryName;
6363

6464
// For root command (proxy itself), use rich logging
@@ -86,7 +86,7 @@ public static ILoggingBuilder ConfigureDevProxyLogging(
8686
formatterOptions.ShowTimestamps = showTimestamps;
8787
}
8888
)
89-
.AddConsoleFormatter<MachineConsoleFormatter, ProxyConsoleFormatterOptions>(formatterOptions =>
89+
.AddConsoleFormatter<JsonConsoleFormatter, ProxyConsoleFormatterOptions>(formatterOptions =>
9090
{
9191
formatterOptions.IncludeScopes = true;
9292
formatterOptions.ShowSkipMessages = showSkipMessages;
@@ -120,7 +120,7 @@ public static ILoggingBuilder ConfigureDevProxyLogging(
120120
formatterOptions.ShowTimestamps = showTimestamps;
121121
}
122122
)
123-
.AddConsoleFormatter<MachineConsoleFormatter, ProxyConsoleFormatterOptions>(formatterOptions =>
123+
.AddConsoleFormatter<JsonConsoleFormatter, ProxyConsoleFormatterOptions>(formatterOptions =>
124124
{
125125
formatterOptions.IncludeScopes = true;
126126
formatterOptions.ShowSkipMessages = showSkipMessages;

DevProxy/Logging/MachineConsoleFormatter.cs renamed to DevProxy/Logging/JsonConsoleFormatter.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
namespace DevProxy.Logging;
1515

16-
sealed class MachineConsoleFormatter : ConsoleFormatter
16+
sealed class JsonConsoleFormatter : ConsoleFormatter
1717
{
18-
public const string FormatterName = "devproxy-machine";
18+
public const string FormatterName = "devproxy-json";
1919

2020
private static readonly JsonSerializerOptions _jsonOptions = new()
2121
{
@@ -55,7 +55,7 @@ sealed class MachineConsoleFormatter : ConsoleFormatter
5555
private readonly ProxyConsoleFormatterOptions _options;
5656
private readonly HashSet<MessageType> _filteredMessageTypes;
5757

58-
public MachineConsoleFormatter(IOptions<ProxyConsoleFormatterOptions> options) : base(FormatterName)
58+
public JsonConsoleFormatter(IOptions<ProxyConsoleFormatterOptions> options) : base(FormatterName)
5959
{
6060
Console.OutputEncoding = Encoding.UTF8;
6161
_options = options.Value;
@@ -101,7 +101,7 @@ private void WriteRequestLog(RequestLog requestLog, string category, IExternalSc
101101
pluginName = pluginName[(pluginName.LastIndexOf('.') + 1)..];
102102
}
103103

104-
var logObject = new MachineRequestLogEntry
104+
var logObject = new JsonRequestLogEntry
105105
{
106106
Type = GetMessageTypeString(messageType),
107107
Message = requestLog.Message,
@@ -142,7 +142,7 @@ private static void WriteRegularLogMessage<TState>(in LogEntry<TState> logEntry,
142142
category = category[(category.LastIndexOf('.') + 1)..];
143143
}
144144

145-
var logObject = new MachineLogEntry
145+
var logObject = new JsonLogEntry
146146
{
147147
Type = "log",
148148
Level = GetLogLevelString(logEntry.LogLevel),
@@ -168,7 +168,7 @@ private static void WriteStructuredOutput(string message, string category, TextW
168168
try
169169
{
170170
var data = JsonSerializer.Deserialize<JsonElement>(message);
171-
var logObject = new MachineResultEntry
171+
var logObject = new JsonResultEntry
172172
{
173173
Type = "result",
174174
Data = data,
@@ -183,7 +183,7 @@ private static void WriteStructuredOutput(string message, string category, TextW
183183
{
184184
// Fallback: if the message isn't valid JSON, write it as a
185185
// regular log entry
186-
var logObject = new MachineLogEntry
186+
var logObject = new JsonLogEntry
187187
{
188188
Type = "result",
189189
Message = message,
@@ -216,8 +216,8 @@ private static string GetLogLevelString(LogLevel logLevel) =>
216216
return requestId;
217217
}
218218

219-
// JSON serialization models for machine output
220-
private sealed class MachineRequestLogEntry
219+
// JSON serialization models for JSON output
220+
private sealed class JsonRequestLogEntry
221221
{
222222
public string? Type { get; set; }
223223
public string? Message { get; set; }
@@ -228,7 +228,7 @@ private sealed class MachineRequestLogEntry
228228
public string? Timestamp { get; set; }
229229
}
230230

231-
private sealed class MachineLogEntry
231+
private sealed class JsonLogEntry
232232
{
233233
public string? Type { get; set; }
234234
public string? Level { get; set; }
@@ -239,7 +239,7 @@ private sealed class MachineLogEntry
239239
public string? Exception { get; set; }
240240
}
241241

242-
private sealed class MachineResultEntry
242+
private sealed class JsonResultEntry
243243
{
244244
public string? Type { get; set; }
245245
public JsonElement? Data { get; set; }

DevProxy/Logging/LogEvents.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ static class LogEvents
88
{
99
/// <summary>
1010
/// EventId for structured output (e.g., JSON from subcommands).
11-
/// When MachineConsoleFormatter sees this EventId, it wraps the message
11+
/// When JsonConsoleFormatter sees this EventId, it wraps the message
1212
/// in a consistent envelope with type "result" and a data field
1313
/// containing the parsed JSON object.
1414
/// </summary>

0 commit comments

Comments
 (0)