Skip to content

Commit c00dcd6

Browse files
author
Mohamad Mahmoud
committed
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
1 parent ad5ae5b commit c00dcd6

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

libs/debugstore/rust/src/core.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl DebugStore {
4848
///
4949
/// This constant is used as a part of the debug store's data format,
5050
/// allowing for version tracking and compatibility checks.
51-
const ENCODE_VERSION: u32 = 2;
51+
const ENCODE_VERSION: u32 = 3;
5252

5353
/// Creates a new instance of `DebugStore` with specified event limit and maximum delay.
5454
fn new() -> Self {
@@ -123,9 +123,11 @@ impl DebugStore {
123123

124124
impl fmt::Display for DebugStore {
125125
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
126+
// Write the debug store header information
126127
let uptime_now = uptimeMillis();
127128
write!(f, "{},{},{}::", Self::ENCODE_VERSION, self.event_store.len(), uptime_now)?;
128129

130+
// Join events with a separator
129131
write!(
130132
f,
131133
"{}",
@@ -136,7 +138,10 @@ impl fmt::Display for DebugStore {
136138
acc.push_str(&event.to_string());
137139
acc
138140
})
139-
)
141+
)?;
142+
143+
// Write the debug store footer
144+
write!(f, ";;")
140145
}
141146
}
142147

0 commit comments

Comments
 (0)