Documentation
//! A Rust logger. Provides macro `debugln!()` and `println!()`.
//!
//! # Example
//! ```
//! rog::reg("main");
//! rog::debugln!("debug");
//! rog::println!("print");
//! ```

use std::collections::HashSet;
pub use std::println;
use std::sync::{LazyLock, Mutex};

pub static C: LazyLock<Mutex<HashSet<&'static str>>> = LazyLock::new(|| Mutex::new(HashSet::new()));

/// Debugs to the standard output, with a newline.
#[macro_export]
macro_rules! debugln {
    ($($arg:tt)*) => ({
        if rog::C.lock().unwrap().contains(module_path!()) {
            print!($($arg)*);
            print!("\n");
        }
    })
}

/// Register a series of module names, the logs in this module will be printed.
pub fn reg(module: &'static str) {
    C.lock().unwrap().insert(module);
}