1use crate::log::level::LogLevel;
2
3#[allow(unused)]
4pub fn init_slice(crate_logging_levels: &[(&str, Option<LogLevel>)]) {
5 let mut filter = String::from("RUST_LOG=off,");
7 let joined: String = crate_logging_levels
8 .iter()
9 .map(|(name, level)| {
10 format!(
11 "{name}={}",
12 match &level {
13 None => "off".to_string(),
14 Some(level) => level.to_string(),
15 }
16 )
17 })
18 .collect::<Vec<String>>()
19 .join(",");
20 filter.push_str(&joined);
21
22 tracing_subscriber::fmt()
23 .with_env_filter(filter)
24 .with_thread_names(true)
25 .init();
28}
29
30#[macro_export]
31macro_rules! log_init_max {
32 () => {{
33 const NAME: &str = env!("CARGO_PKG_NAME");
34 $crate::log::init::init_slice(&[("RUST_LOG", None), (NAME, Some($crate::log::level::LogLevel::Trace))])
35 }};
36}
37
38#[macro_export]
39macro_rules! log_init {
40 ($level:expr) => {{
41 const NAME: &str = env!("CARGO_PKG_NAME");
42 $crate::log::init::init_slice(&[("RUST_LOG", None), (NAME, $level)])
43 }};
44}
45
46#[macro_export]
48macro_rules! log_init_multiple {
49 ($($levels:expr),+) => {{
50 $crate::log::init::init_slice(&[("RUST_LOG", None), $($levels),+])
51 }};
52}
53
54#[macro_export]
55macro_rules! log_init_with_others {
56 ($level:expr, $($levels:expr),+) => {{
57 const NAME: &str = env!("CARGO_PKG_NAME");
58 $crate::log::init::init_slice(&[("RUST_LOG", None), (NAME, $level), $($levels),+])
59 }};
60}