chore: re-adding 'Paymo' prefix in front of all classes
This commit is contained in:
45
src/Shared/PaymoLoggingHandler.cs
Normal file
45
src/Shared/PaymoLoggingHandler.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Novaloop.PaymoApi.Shared
|
||||
{
|
||||
public class PaymoLoggingHandler : DelegatingHandler
|
||||
{
|
||||
private readonly ILogger<PaymoLoggingHandler> _logger;
|
||||
|
||||
public PaymoLoggingHandler(ILogger<PaymoLoggingHandler> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public PaymoLoggingHandler(HttpMessageHandler innerHandler, ILogger<PaymoLoggingHandler> logger)
|
||||
: base(innerHandler)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
||||
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||
{
|
||||
_logger.LogDebug($"Request:\n{request}");
|
||||
if (request.Content != null)
|
||||
{
|
||||
var body = await request.Content.ReadAsStringAsync();
|
||||
_logger.LogDebug(body);
|
||||
}
|
||||
|
||||
var response = await base.SendAsync(request, cancellationToken);
|
||||
|
||||
_logger.LogDebug($"Response:\n{response}");
|
||||
if (response.Content != null)
|
||||
{
|
||||
var body = await response.Content.ReadAsStringAsync();
|
||||
_logger.LogDebug(body);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user