1#[macro_export]
15#[doc(hidden)]
16macro_rules! __log_keep_used {
17 ($($arg:tt)*) => {{
18 #[cfg(not(debug_assertions))]
19 if false { let _ = format_args!($($arg)*); }
20 }};
21}
22
23#[macro_export]
24macro_rules! log_info {
25 ($($arg:tt)*) => {{
26 #[cfg(debug_assertions)]
27 if $crate::logging::level_enabled($crate::logging::LEVEL_INFO) {
28 eprintln!("[INFO] {}", format_args!($($arg)*));
29 }
30 $crate::__log_keep_used!($($arg)*);
31 }};
32}
33
34#[macro_export]
35macro_rules! log_debug {
36 ($($arg:tt)*) => {{
37 #[cfg(debug_assertions)]
38 if $crate::logging::level_enabled($crate::logging::LEVEL_DEBUG) {
39 eprintln!("[DEBUG] {}", format_args!($($arg)*));
40 }
41 $crate::__log_keep_used!($($arg)*);
42 }};
43}
44
45#[macro_export]
46macro_rules! log_trace {
47 ($($arg:tt)*) => {{
48 #[cfg(debug_assertions)]
49 if $crate::logging::level_enabled($crate::logging::LEVEL_TRACE) {
50 eprintln!("[TRACE] {}", format_args!($($arg)*));
51 }
52 $crate::__log_keep_used!($($arg)*);
53 }};
54}
55
56#[macro_export]
57macro_rules! log_warn {
58 ($($arg:tt)*) => {{
59 if $crate::logging::level_enabled($crate::logging::LEVEL_WARN) {
60 let _secs = std::time::SystemTime::now()
61 .duration_since(std::time::UNIX_EPOCH)
62 .unwrap_or_default()
63 .as_secs();
64 eprintln!("[WARN {:02}:{:02}:{:02}Z] {}", (_secs / 3600) % 24, (_secs / 60) % 60, _secs % 60, format_args!($($arg)*));
65 }
66 }};
67}
68
69#[macro_export]
74macro_rules! log_net_fail {
75 ($($arg:tt)*) => {{
76 let msg = format!($($arg)*);
77 if $crate::logging::level_enabled($crate::logging::LEVEL_WARN) {
80 eprintln!("[WARN] {}", &msg);
81 }
82 $crate::logging::persist(&format!(
83 "[{} WARN] {}",
84 $crate::logging::timestamp_utc(),
85 &msg
86 ));
87 }};
88}
89
90#[macro_export]
95macro_rules! log_net_info {
96 ($($arg:tt)*) => {{
97 let msg = format!($($arg)*);
98 #[cfg(debug_assertions)]
99 if $crate::logging::level_enabled($crate::logging::LEVEL_INFO) {
100 eprintln!("[INFO] {}", &msg);
101 }
102 $crate::logging::persist(&format!(
103 "[{} INFO] {}",
104 $crate::logging::timestamp_utc(),
105 &msg
106 ));
107 }};
108}