Debug logging in BuildHeaderAndExecuteRequests

This commit is contained in:
Casper Sparre 2025-05-14 00:06:57 +02:00
parent 3d4dfbae17
commit d3b8ca6fcd

View File

@ -14,6 +14,7 @@ using OF_DL.Enumerations;
using OF_DL.Enumurations;
using Serilog;
using Spectre.Console;
using System.Diagnostics;
using System.Globalization;
using System.Security.Cryptography;
using System.Text;
@ -129,7 +130,14 @@ public class APIHelper : IAPIHelper
try
{
HttpRequestMessage request = await BuildHttpRequestMessage(getParams, endpoint, method);
Debug.WriteLine($"Executing {request.Method.Method.ToUpper()} request: {request.RequestUri}\r\n\t{GetParamsString(getParams)}");
using var response = await client.SendAsync(request);
if (Debugger.IsAttached && !response.IsSuccessStatusCode)
Debugger.Break();
response.EnsureSuccessStatusCode();
string body = await response.Content.ReadAsStringAsync();
@ -147,6 +155,9 @@ public class APIHelper : IAPIHelper
throw;
}
static string GetParamsString(Dictionary<string, string> getParams)
=> string.Join(" | ", getParams.Select(kv => $"{kv.Key}={kv.Value}"));
}