pumpkin_core/statistics/
statistic_logger.rs1use std::fmt::Display;
2
3use itertools::Itertools;
4
5use super::statistic_logging::log_statistic;
6#[cfg(doc)]
7use crate::engine::propagation::Propagator;
8
9#[derive(Debug, Default, Clone)]
12pub struct StatisticLogger {
13 name_prefix: String,
15}
16
17impl StatisticLogger {
18 pub fn new<Input: IntoIterator<Item = impl Display>>(name_prefix: Input) -> Self {
19 Self {
20 name_prefix: name_prefix.into_iter().join("_"),
21 }
22 }
23
24 pub fn attach_to_prefix(&self, addition_to_prefix: impl Display) -> Self {
27 Self {
28 name_prefix: format!("{}_{}", self.name_prefix, addition_to_prefix),
29 }
30 }
31
32 pub fn log_statistic(&self, value: impl Display) {
33 log_statistic(&self.name_prefix, value);
34 }
35}