Add ILogger support for enhanced API call logging
Introduced optional ILogger support across BaseCrudApi and its derived classes to enable logging of API call outcomes. Updated constructors to accept an optional ILogger parameter, with conditional compilation for .NET Framework compatibility. Replaced EnsureSuccessAsync with HandleResponseAsync in CRUD methods to integrate logging. Updated derived API classes (CommonApi, EndpointAuthApi, EndpointParamsApi, EndpointsApi, ProfileApi, RecActionApi, ResultApi) to pass ILogger to the base class. Added Microsoft.Extensions.Logging imports and ensured backward compatibility by making ILogger optional and handling nullable reference types in non-.NET Framework environments.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace ReC.Client.Api
|
||||
{
|
||||
@@ -13,7 +14,12 @@ namespace ReC.Client.Api
|
||||
/// Initializes a new instance of the <see cref="EndpointsApi"/> class.
|
||||
/// </summary>
|
||||
/// <param name="http">The HTTP client used for requests.</param>
|
||||
public EndpointsApi(HttpClient http) : base(http, "api/Endpoints")
|
||||
/// <param name="logger">An optional logger used to record API call outcomes.</param>
|
||||
#if NETFRAMEWORK
|
||||
public EndpointsApi(HttpClient http, ILogger logger = null) : base(http, "api/Endpoints", logger)
|
||||
#else
|
||||
public EndpointsApi(HttpClient http, ILogger? logger = null) : base(http, "api/Endpoints", logger)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user