Skip to main content

rust_covfix/
logger.rs

1#![allow(unused_macros)]
2
3use std::sync::atomic::{self, Ordering};
4
5static VERBOSITY: atomic::AtomicUsize = atomic::AtomicUsize::new(0);
6
7pub fn set_verbosity(verbosity: usize) {
8    VERBOSITY.store(verbosity, Ordering::SeqCst);
9}
10
11pub fn get_verbosity() -> usize {
12    VERBOSITY.load(Ordering::SeqCst)
13}
14
15#[doc(hidden)]
16#[macro_export]
17macro_rules! errorln {
18    ($($arg:tt)*) => {
19        if $crate::get_verbosity() >= 1 {
20            eprintln!($($arg)*);
21        }
22    };
23}
24
25#[doc(hidden)]
26#[macro_export]
27macro_rules! warnln {
28    ($($arg:tt)*) => {
29        if $crate::get_verbosity() >= 2 {
30            eprintln!($($arg)*);
31        }
32    };
33}
34
35#[doc(hidden)]
36#[macro_export]
37macro_rules! infoln {
38    ($($arg:tt)*) => {
39        if $crate::get_verbosity() >= 3 {
40            eprintln!($($arg)*);
41        }
42    };
43}
44
45#[doc(hidden)]
46#[macro_export]
47macro_rules! debugln {
48    ($($arg:tt)*) => {
49        if $crate::get_verbosity() >= 4 {
50            eprintln!($($arg)*);
51        }
52    };
53}