From 12fe94cbffd11967131faf7a0553a93b1e22d912 Mon Sep 17 00:00:00 2001 From: Jkorf Date: Tue, 1 Mar 2022 10:41:51 +0100 Subject: [PATCH] Added ApiName to time sync state for logging --- CryptoExchange.Net/Objects/TimeSyncState.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CryptoExchange.Net/Objects/TimeSyncState.cs b/CryptoExchange.Net/Objects/TimeSyncState.cs index 74b0b8c..b4caf03 100644 --- a/CryptoExchange.Net/Objects/TimeSyncState.cs +++ b/CryptoExchange.Net/Objects/TimeSyncState.cs @@ -10,6 +10,10 @@ namespace CryptoExchange.Net.Objects /// public class TimeSyncState { + /// + /// Name of the API + /// + public string ApiName { get; set; } /// /// Semaphore to use for checking the time syncing. Should be shared instance among the API client /// @@ -26,8 +30,9 @@ namespace CryptoExchange.Net.Objects /// /// ctor /// - public TimeSyncState() + public TimeSyncState(string apiName) { + ApiName = apiName; Semaphore = new SemaphoreSlim(1, 1); } } @@ -78,12 +83,12 @@ namespace CryptoExchange.Net.Objects TimeSyncState.LastSyncTime = DateTime.UtcNow; if (offset.TotalMilliseconds > 0 && offset.TotalMilliseconds < 500) { - Log.Write(LogLevel.Information, $"Time offset within limits, set offset to 0ms"); + Log.Write(LogLevel.Information, $"{TimeSyncState.ApiName} Time offset within limits, set offset to 0ms"); TimeSyncState.TimeOffset = TimeSpan.Zero; } else { - Log.Write(LogLevel.Information, $"Time offset set to {Math.Round(offset.TotalMilliseconds)}ms"); + Log.Write(LogLevel.Information, $"{TimeSyncState.ApiName} Time offset set to {Math.Round(offset.TotalMilliseconds)}ms"); TimeSyncState.TimeOffset = offset; } }