Cache/PathCanon/SpawnDiagnosticLogger.rs
1//! Spawn a tokio task that logs cache stats every 30s under the
2//! `path-canon` target. Optional - call from the embedder's runtime
3//! setup when the user has the `path-canon` tag enabled.
4
5use std::time::Duration;
6
7use crate::PathCanon::Stats;
8
9pub fn Fn() {
10 tokio::spawn(async {
11 let mut Interval = tokio::time::interval(Duration::from_secs(30));
12
13 Interval.tick().await;
14
15 loop {
16 Interval.tick().await;
17
18 let Snapshot = Stats::Fn();
19
20 log::debug!(
21 target:"path-canon",
22
23 "entries={} weighted={}",
24
25 Snapshot.Entries,
26
27 Snapshot.WeightedSize
28 );
29 }
30 });
31}