Skip to content

Commit

Permalink
Resolve PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
garrytrinder committed Dec 13, 2024
1 parent 048153c commit 76ba9c3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
4 changes: 3 additions & 1 deletion dev-proxy/Logging/ProxyConsoleFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ private void LogRequest(RequestLog requestLog, string category, IExternalScopePr

// don't log intercepted response to console
if (messageType == MessageType.InterceptedResponse ||
(messageType == MessageType.Skipped && !_options.ShowSkipMessages))
(messageType == MessageType.Skipped && !_options.ShowSkipMessages) ||
(messageType == MessageType.Timestamp && !_options.ShowTimestamps)
)
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion dev-proxy/Logging/ProxyConsoleFormatterOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ public class ProxyConsoleFormatterOptions: ConsoleFormatterOptions
{
public bool ShowSkipMessages { get; set; } = true;

public bool ShowTimestamps { get; set; } = false;
public bool ShowTimestamps { get; set; } = true;
}
9 changes: 3 additions & 6 deletions dev-proxy/ProxyEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -475,16 +475,13 @@ async Task OnRequestAsync(object sender, SessionEventArgs e)
await e.GetRequestBodyAsString();
}

using var scope = _logger?.BeginScope(e.HttpClient.Request.Method ?? "", e.HttpClient.Request.Url, e.GetHashCode());
using var scope = _logger.BeginScope(e.HttpClient.Request.Method ?? "", e.HttpClient.Request.Url, e.GetHashCode());

e.UserData = e.HttpClient.Request;

_logger?.LogRequest($"{e.HttpClient.Request.Method} {e.HttpClient.Request.Url}", MessageType.InterceptedRequest, new LoggingContext(e));
_logger.LogRequest($"{e.HttpClient.Request.Method} {e.HttpClient.Request.Url}", MessageType.InterceptedRequest, new LoggingContext(e));

if (_config.ShowTimestamps)
{
_logger?.LogRequest($"{DateTimeOffset.UtcNow}", MessageType.Timestamp, new LoggingContext(e));
}
_logger.LogRequest($"{DateTimeOffset.UtcNow}", MessageType.Timestamp, new LoggingContext(e));

await HandleRequestAsync(e, proxyRequestArgs);
}
Expand Down

0 comments on commit 76ba9c3

Please sign in to comment.