1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-08-17 03:12:56 +00:00

added optional request tracing id for much better logs reading

This commit is contained in:
Артем Курьянов
2020-08-14 14:15:13 +00:00
parent 4b1baf8b82
commit 9b8950747f
7 changed files with 44 additions and 165 deletions
@@ -12,10 +12,11 @@ namespace CryptoExchange.Net.Requests
public class RequestFactory : IRequestFactory
{
private HttpClient? httpClient;
private bool isTracingEnabled;
/// <inheritdoc />
public void Configure(TimeSpan requestTimeout, ApiProxy? proxy)
public void Configure(TimeSpan requestTimeout, ApiProxy? proxy, bool isTracingEnabled = false)
{
this.isTracingEnabled = isTracingEnabled;
HttpMessageHandler handler = new HttpClientHandler()
{
Proxy = proxy == null ? null : new WebProxy
@@ -25,7 +26,7 @@ namespace CryptoExchange.Net.Requests
}
};
httpClient = new HttpClient(handler) {Timeout = requestTimeout};
httpClient = new HttpClient(handler) { Timeout = requestTimeout };
}
/// <inheritdoc />
@@ -34,7 +35,7 @@ namespace CryptoExchange.Net.Requests
if (httpClient == null)
throw new InvalidOperationException("Cant create request before configuring http client");
return new Request(new HttpRequestMessage(method, uri), httpClient);
return new Request(new HttpRequestMessage(method, uri), httpClient, isTracingEnabled);
}
}
}