use super::{BootstrapResult, LOG_TARGET, LifecycleStep, debug};
pub(super) fn timed_step(
step: LifecycleStep,
run: impl FnOnce() -> BootstrapResult<()>,
) -> BootstrapResult<()> {
let started = std::time::Instant::now();
let outcome = run();
log_step_finished(step, started);
outcome
}
#[cfg(feature = "async-api")]
pub(super) async fn timed_step_async(
step: LifecycleStep,
run: impl std::future::Future<Output = BootstrapResult<()>>,
) -> BootstrapResult<()> {
let started = std::time::Instant::now();
let outcome = run.await;
log_step_finished(step, started);
outcome
}
fn log_step_finished(step: LifecycleStep, started: std::time::Instant) {
debug!(
target: LOG_TARGET,
step = step.name(),
elapsed_ms = started.elapsed().as_millis(),
"lifecycle step finished"
);
}