pub struct StorageEventLog { /* private fields */ }Expand description
A bounded, queryable log of StorageEvents.
When the number of stored events exceeds max_events, the oldest
event is evicted on each new insertion.
Implementations§
Source§impl StorageEventLog
impl StorageEventLog
Sourcepub fn new(max_events: usize) -> Self
pub fn new(max_events: usize) -> Self
Create a new event log that retains at most max_events entries.
Sourcepub fn log(
&mut self,
event_type: EventType,
severity: EventSeverity,
message: &str,
block_cid: Option<&str>,
metadata: HashMap<String, String>,
) -> u64
pub fn log( &mut self, event_type: EventType, severity: EventSeverity, message: &str, block_cid: Option<&str>, metadata: HashMap<String, String>, ) -> u64
Append a new event and return its unique id.
If the log has reached max_events, the oldest event is evicted first.
Sourcepub fn get_event(&self, id: u64) -> Option<&StorageEvent>
pub fn get_event(&self, id: u64) -> Option<&StorageEvent>
Look up an event by its id.
Sourcepub fn events_by_type(&self, event_type: EventType) -> Vec<&StorageEvent>
pub fn events_by_type(&self, event_type: EventType) -> Vec<&StorageEvent>
Return all events matching the given EventType.
Sourcepub fn events_by_severity(&self, severity: EventSeverity) -> Vec<&StorageEvent>
pub fn events_by_severity(&self, severity: EventSeverity) -> Vec<&StorageEvent>
Return all events matching the given EventSeverity.
Sourcepub fn events_since(&self, tick: u64) -> Vec<&StorageEvent>
pub fn events_since(&self, tick: u64) -> Vec<&StorageEvent>
Return all events whose tick is strictly greater than tick.
Sourcepub fn count_by_type(&self, event_type: EventType) -> u64
pub fn count_by_type(&self, event_type: EventType) -> u64
Return the cumulative count of events of the given type (including evicted events).
Sourcepub fn recent(&self, n: usize) -> Vec<&StorageEvent>
pub fn recent(&self, n: usize) -> Vec<&StorageEvent>
Return the last n events (or fewer if the log is smaller).
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Remove all events from the log.
Cumulative type counts and the current tick are preserved.
Sourcepub fn event_count(&self) -> usize
pub fn event_count(&self) -> usize
Return the number of events currently in the log.
Sourcepub fn stats(&self) -> EventLogStats
pub fn stats(&self) -> EventLogStats
Compute aggregate statistics over the current event log.
Auto Trait Implementations§
impl Freeze for StorageEventLog
impl RefUnwindSafe for StorageEventLog
impl Send for StorageEventLog
impl Sync for StorageEventLog
impl Unpin for StorageEventLog
impl UnsafeUnpin for StorageEventLog
impl UnwindSafe for StorageEventLog
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more