cuprate_benchmark/
log.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use cfg_if::cfg_if;
use tracing::{info, instrument, Level};
use tracing_subscriber::FmtSubscriber;

/// Initializes the `tracing` logger.
#[instrument]
pub(crate) fn init_logger() {
    const LOG_LEVEL: Level = {
        cfg_if! {
            if #[cfg(feature = "trace")] {
                Level::TRACE
            } else if #[cfg(feature = "debug")] {
                Level::DEBUG
            } else if #[cfg(feature = "warn")] {
                Level::WARN
            } else if #[cfg(feature = "info")] {
                Level::INFO
            } else if #[cfg(feature = "error")] {
                Level::ERROR
            } else {
                Level::INFO
            }
        }
    };

    FmtSubscriber::builder().with_max_level(LOG_LEVEL).init();

    info!("Log level: {LOG_LEVEL}");
}