Struct base::periodic_logger::PeriodicLogger
source · pub struct PeriodicLogger {
name: String,
interval: Duration,
counters: Arc<RwLock<HashMap<String, AtomicU32>>>,
worker_thread: Option<WorkerThread<Result<(), PeriodicLoggerError>>>,
}
Expand description
Utility class that helps count and log high frequency events periodically.
Fields§
§name: String
§interval: Duration
§counters: Arc<RwLock<HashMap<String, AtomicU32>>>
§worker_thread: Option<WorkerThread<Result<(), PeriodicLoggerError>>>
Implementations§
source§impl PeriodicLogger
impl PeriodicLogger
pub fn new(name: String, interval: Duration) -> Self
sourcepub fn add_counter_item(&self, name: String) -> Result<(), PeriodicLoggerError>
pub fn add_counter_item(&self, name: String) -> Result<(), PeriodicLoggerError>
Add a new event item to be counted.
sourcepub fn increment_counter(
&self,
name: String,
amount: u32
) -> Result<(), PeriodicLoggerError>
pub fn increment_counter( &self, name: String, amount: u32 ) -> Result<(), PeriodicLoggerError>
Increment event counter by an amount
sourcepub fn start_logging_thread(&mut self) -> Result<(), PeriodicLoggerError>
pub fn start_logging_thread(&mut self) -> Result<(), PeriodicLoggerError>
Starts a thread that will log the count of events within a self.interval
time period.
All counters will be reset to 0 after logging.
Auto Trait Implementations§
impl !RefUnwindSafe for PeriodicLogger
impl Send for PeriodicLogger
impl Sync for PeriodicLogger
impl Unpin for PeriodicLogger
impl !UnwindSafe for PeriodicLogger
Blanket Implementations§
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
Mutably borrows from an owned value. Read more