From 3fc28092b468feb13e692a3276724a419a2c3684 Mon Sep 17 00:00:00 2001 From: sakno Date: Thu, 2 May 2024 14:40:26 +0300 Subject: [PATCH] Improved logging --- .../Net/Cluster/Consensus/Raft/LeaderState.Replication.cs | 4 ++-- .../Net/Cluster/Consensus/Raft/LogMessages.cs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cluster/DotNext.Net.Cluster/Net/Cluster/Consensus/Raft/LeaderState.Replication.cs b/src/cluster/DotNext.Net.Cluster/Net/Cluster/Consensus/Raft/LeaderState.Replication.cs index 10896c634..225b81e36 100644 --- a/src/cluster/DotNext.Net.Cluster/Net/Cluster/Consensus/Raft/LeaderState.Replication.cs +++ b/src/cluster/DotNext.Net.Cluster/Net/Cluster/Consensus/Raft/LeaderState.Replication.cs @@ -111,7 +111,7 @@ internal ValueTask> ReplicateAsync(IAuditTrail audit var startIndex = replicationIndex + 1L; Debug.Assert(startIndex == Member.State.NextIndex); - logger.ReplicationStarted(Member.EndPoint, startIndex); + logger.ReplicationStarted(Member.EndPoint, startIndex, currentIndex); return auditTrail.ReadAsync(this, startIndex, currentIndex, token); } @@ -168,7 +168,7 @@ private ConfiguredTaskAwaitable>.ConfiguredTaskAwaiter R { Debug.Assert(snapshot.IsSnapshot); - logger.InstallingSnapshot(replicationIndex = snapshotIndex); + logger.InstallingSnapshot(Member.EndPoint, replicationIndex = snapshotIndex); var result = Member.InstallSnapshotAsync(term, snapshot, snapshotIndex, token).ConfigureAwait(false).GetAwaiter(); fingerprint = Member.State.ConfigurationFingerprint; // keep local version unchanged return result; diff --git a/src/cluster/DotNext.Net.Cluster/Net/Cluster/Consensus/Raft/LogMessages.cs b/src/cluster/DotNext.Net.Cluster/Net/Cluster/Consensus/Raft/LogMessages.cs index 4d305b545..d57dd14ca 100644 --- a/src/cluster/DotNext.Net.Cluster/Net/Cluster/Consensus/Raft/LogMessages.cs +++ b/src/cluster/DotNext.Net.Cluster/Net/Cluster/Consensus/Raft/LogMessages.cs @@ -110,10 +110,10 @@ internal static partial class LogMessages [LoggerMessage( EventIdOffset + 12, LogLevel.Debug, - "Replication of member {Member} started at log index {EntryIndex}", + "Replication of member {Member} started from {StartIndex} log index to {EndIndex}", EventName = $"{EventIdPrefix}.{nameof(ReplicationStarted)}" )] - public static partial void ReplicationStarted(this ILogger logger, EndPoint member, long entryIndex); + public static partial void ReplicationStarted(this ILogger logger, EndPoint member, long startIndex, long endIndex); [LoggerMessage( EventIdOffset + 13, @@ -158,10 +158,10 @@ internal static partial class LogMessages [LoggerMessage( EventIdOffset + 18, LogLevel.Information, - "Installing snapshot at index {EntryIndex}", + "Installing snapshot at index {EntryIndex} for member {Member}", EventName = $"{EventIdPrefix}.{nameof(InstallingSnapshot)}" )] - public static partial void InstallingSnapshot(this ILogger logger, long entryIndex); + public static partial void InstallingSnapshot(this ILogger logger, EndPoint member, long entryIndex); public const string SnapshotInstallationFailed = "Critical error detected while installing snapshot of audit trail";