From c00dcd6f7904e396ffe1132ffba166d6aa345c85 Mon Sep 17 00:00:00 2001 From: Mohamad Mahmoud Date: Mon, 10 Feb 2025 11:38:52 +0000 Subject: Add a footer to the Debug store Update the debug store to include a footer (;;) to allow accurate identification of truncated store instances, and bump up its encoding version Bug: 394834329 Test: atest libdebugstore_tests Flag: EXEMPT bug fix Change-Id: Ia32b8920d4af9cd3b8698532fbf1c53cbf16ac65 --- libs/debugstore/rust/src/core.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libs/debugstore/rust/src/core.rs b/libs/debugstore/rust/src/core.rs index a8acdedc55..16147dd092 100644 --- a/libs/debugstore/rust/src/core.rs +++ b/libs/debugstore/rust/src/core.rs @@ -48,7 +48,7 @@ impl DebugStore { /// /// This constant is used as a part of the debug store's data format, /// allowing for version tracking and compatibility checks. - const ENCODE_VERSION: u32 = 2; + const ENCODE_VERSION: u32 = 3; /// Creates a new instance of `DebugStore` with specified event limit and maximum delay. fn new() -> Self { @@ -123,9 +123,11 @@ impl DebugStore { impl fmt::Display for DebugStore { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + // Write the debug store header information let uptime_now = uptimeMillis(); write!(f, "{},{},{}::", Self::ENCODE_VERSION, self.event_store.len(), uptime_now)?; + // Join events with a separator write!( f, "{}", @@ -136,7 +138,10 @@ impl fmt::Display for DebugStore { acc.push_str(&event.to_string()); acc }) - ) + )?; + + // Write the debug store footer + write!(f, ";;") } } -- cgit v1.2.3-59-g8ed1b