Skip to main content

Module logger

Module logger 

Source
Expand description

Convenience wrapper that injects timestamps from a user-provided clock.

SensorLogger wraps anything that can take a sample — a SensorDb, a TieredDb, or any other LogSink — together with a clock function, eliminating the need to pass a timestamp on every append call.

§Example

ⓘ
use sensor_db::{SensorDb, SensorLogger};

let db: SensorDb<_, 256, 32> = SensorDb::new(flash, 0, 32, 2)?;
let mut logger = SensorLogger::new(db, || get_timestamp_us());

logger.log(&Temperature { celsius: 25.5 })?;
logger.sync()?;

The same wrapper over a tier, so a card can come and go beneath it:

ⓘ
let mut logger = SensorLogger::new(tiered, || get_timestamp_us());
logger.log(&Temperature { celsius: 25.5 })?;

Structs§

SensorLogger
A convenience wrapper around a LogSink that automatically timestamps entries.
SensorLoggerAsync
Async version of SensorLogger, wrapping any LogSinkAsync.