simple_log/
macros.rs

1#[macro_export(local_inner_macros)]
2macro_rules! error {
3    (target: $target:expr, $($arg:tt)+) => (
4        $crate::log::error!(target: $target, $($arg)+)
5
6    );
7    ($($arg:tt)+) => (
8        $crate::log::error!($($arg)+);
9    )
10}
11
12#[macro_export(local_inner_macros)]
13macro_rules! warn {
14    (target: $target:expr, $($arg:tt)+) => (
15        $crate::log::warn!(target: $target, $($arg)+)
16
17    );
18    ($($arg:tt)+) => (
19        $crate::log::warn!($($arg)+);
20    )
21}
22
23#[macro_export(local_inner_macros)]
24macro_rules! info {
25    (target: $target:expr, $($arg:tt)+) => (
26        $crate::log::info!(target: $target, $($arg)+)
27
28    );
29    ($($arg:tt)+) => (
30        $crate::log::info!($($arg)+);
31    )
32}
33
34#[macro_export(local_inner_macros)]
35macro_rules! debug {
36    (target: $target:expr, $($arg:tt)+) => (
37        $crate::log::debug!(target: $target, $($arg)+)
38
39    );
40    ($($arg:tt)+) => (
41        $crate::log::debug!($($arg)+);
42    )
43}
44
45#[macro_export(local_inner_macros)]
46macro_rules! trace {
47    (target: $target:expr, $($arg:tt)+) => (
48        $crate::log::trace!(target: $target, $($arg)+)
49
50    );
51    ($($arg:tt)+) => (
52        $crate::log::trace!($($arg)+);
53    )
54}
55
56#[cfg(feature = "target")]
57#[macro_export(local_inner_macros)]
58macro_rules! log_target {
59    ($($x:expr),+ $(,)?) => {
60        $(
61            $crate::log_target_derive!($x);
62        )+
63    };
64    ($arg:expr) => {
65        $crate::log_target_derive!($arg);
66    };
67}
68
69#[macro_export]
70macro_rules! quick {
71    () => {
72        $crate::quick_log_level::<_, &str>($crate::Level::Debug, None).unwrap()
73    };
74    ($level:expr) => {{
75        $crate::quick_log_level::<_, &str>($level, None).unwrap()
76    }};
77    ($level:expr,$path:expr) => {{
78        $crate::quick_log_level($level, Some($path)).unwrap()
79    }};
80}
81
82#[cfg(feature = "println")]
83#[macro_export]
84macro_rules! println {
85    ($($arg:tt)+) => (
86
87        $crate::SIMPLE_LOG_INSTANCE.get_or_init(|| {
88            $crate::new(
89                    $crate::LogConfigBuilder::builder()
90                        .output_console()
91                        .time_format($crate::DEFAULT_HOUR_TIME_FORMAT)
92                        .build()
93                ).unwrap();
94        });
95
96        $crate::log::debug!($($arg)+);
97    )
98}