From b9ea8ad3fe83795c111e279c903bbd1b33dd6643 Mon Sep 17 00:00:00 2001
From: Georgy Moshkin <gmoshkin@picodata.io>
Date: Fri, 17 Jun 2022 14:49:31 +0300
Subject: [PATCH] refactor: more informative Debug for Entry

---
 src/traft/mod.rs | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/traft/mod.rs b/src/traft/mod.rs
index 733a5604cd..7d21ff129e 100644
--- a/src/traft/mod.rs
+++ b/src/traft/mod.rs
@@ -91,7 +91,7 @@ impl Peer {}
 /// See correspondig definition in `raft-rs`:
 /// - <https://github.com/tikv/raft-rs/blob/v0.6.0/proto/proto/eraftpb.proto#L23>
 ///
-#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
+#[derive(Clone, Serialize, Deserialize, PartialEq)]
 pub struct Entry {
     /// ```
     /// enum EntryType {
@@ -112,6 +112,21 @@ pub struct Entry {
     pub context: Option<EntryContext>,
 }
 
+impl std::fmt::Debug for Entry {
+    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+        f.debug_struct("Entry")
+            .field(
+                "entry_type",
+                &raft::EntryType::from_i32(self.entry_type).ok_or(self.entry_type),
+            )
+            .field("index", &self.index)
+            .field("term", &self.term)
+            .field("data", &self.data)
+            .field("context", &self.context)
+            .finish()
+    }
+}
+
 /// Raft entry payload specific to the Picodata.
 #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
 #[serde(untagged)]
-- 
GitLab