1#[doc(hidden)]
5#[macro_export]
6macro_rules! __log_easy_nonfallible {
7 ($method:ident, $($arg:tt)*) => {{
8 if let Some(logger) = $crate::global_logger() {
9 logger.$method(&format!($($arg)*));
10 } else {
11 eprintln!("log-easy: global logger not initialized (call log_easy::init or init_with)");
12 }
13 }};
14}
15
16#[doc(hidden)]
18#[macro_export]
19macro_rules! __log_easy_fallible {
20 ($method:ident, $($arg:tt)*) => {{
21 match $crate::global_logger() {
22 Some(logger) => logger.$method(&format!($($arg)*)),
23 None => Err(std::io::Error::new(
24 std::io::ErrorKind::NotFound,
25 "log-easy: global logger not initialized (call log_easy::init or init_with)",
26 )),
27 }
28 }};
29}
30
31#[macro_export]
32macro_rules! trace { ($($arg:tt)*) => { $crate::__log_easy_nonfallible!(trace, $($arg)*) }; }
33#[macro_export]
34macro_rules! debug { ($($arg:tt)*) => { $crate::__log_easy_nonfallible!(debug, $($arg)*) }; }
35#[macro_export]
36macro_rules! info { ($($arg:tt)*) => { $crate::__log_easy_nonfallible!(info, $($arg)*) }; }
37#[macro_export]
38macro_rules! warn { ($($arg:tt)*) => { $crate::__log_easy_nonfallible!(warn, $($arg)*) }; }
39#[macro_export]
40macro_rules! error { ($($arg:tt)*) => { $crate::__log_easy_nonfallible!(error, $($arg)*) }; }
41
42#[macro_export]
43macro_rules! try_trace { ($($arg:tt)*) => { $crate::__log_easy_fallible!(try_trace, $($arg)*) }; }
44#[macro_export]
45macro_rules! try_debug { ($($arg:tt)*) => { $crate::__log_easy_fallible!(try_debug, $($arg)*) }; }
46#[macro_export]
47macro_rules! try_info { ($($arg:tt)*) => { $crate::__log_easy_fallible!(try_info, $($arg)*) }; }
48#[macro_export]
49macro_rules! try_warn { ($($arg:tt)*) => { $crate::__log_easy_fallible!(try_warn, $($arg)*) }; }
50#[macro_export]
51macro_rules! try_error { ($($arg:tt)*) => { $crate::__log_easy_fallible!(try_error, $($arg)*) }; }