From 01ac7ece1e568c6dd898d5193605c2f5a5ece58d Mon Sep 17 00:00:00 2001 From: TekH Date: Tue, 19 May 2026 19:20:37 +0200 Subject: [PATCH] Add optional logging control to HandleResponseAsync The HandleResponseAsync method was updated to include a new optional parameter, `logSuccess`, which allows control over whether successful HTTP responses are logged. The default value is `true`. This change applies to both `NETFRAMEWORK` and non-`NETFRAMEWORK` builds. The method's XML documentation was updated to reflect this new behavior. --- src/ReC.Client/ReCClientHelpers.cs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/ReC.Client/ReCClientHelpers.cs b/src/ReC.Client/ReCClientHelpers.cs index a0b6342..a7c5595 100644 --- a/src/ReC.Client/ReCClientHelpers.cs +++ b/src/ReC.Client/ReCClientHelpers.cs @@ -48,16 +48,17 @@ namespace ReC.Client /// /// Logs the outcome of an HTTP response. Throws a when the - /// response indicates a non-success status code; otherwise writes an informational log entry - /// containing the request and response details. + /// response indicates a non-success status code; otherwise (optionally) writes an informational + /// log entry containing the request and response details. /// /// The HTTP response to inspect. /// An optional logger used to record the outcome. May be . + /// When , successful responses are not logged. /// A token to cancel the operation. #if NETFRAMEWORK - public static async Task HandleResponseAsync(HttpResponseMessage response, ILogger logger = null, CancellationToken cancel = default) + public static async Task HandleResponseAsync(HttpResponseMessage response, ILogger logger = null, bool logSuccess = true, CancellationToken cancel = default) #else - public static async Task HandleResponseAsync(HttpResponseMessage response, ILogger? logger = null, CancellationToken cancel = default) + public static async Task HandleResponseAsync(HttpResponseMessage response, ILogger? logger = null, bool logSuccess = true, CancellationToken cancel = default) #endif { var request = response.RequestMessage; @@ -67,12 +68,15 @@ namespace ReC.Client if (response.IsSuccessStatusCode) { - logger?.LogInformation( - "ReC API request succeeded. {Method} {Uri} -> {StatusCode} ({ReasonPhrase})", - method, - uri, - statusCode, - response.ReasonPhrase); + if (logSuccess) + { + logger?.LogInformation( + "ReC API request succeeded. {Method} {Uri} -> {StatusCode} ({ReasonPhrase})", + method, + uri, + statusCode, + response.ReasonPhrase); + } return; }