#[macro_export]
#[doc(hidden)]
macro_rules! __log_keep_used {
($($arg:tt)*) => {{
#[cfg(not(debug_assertions))]
if false { let _ = format_args!($($arg)*); }
}};
}
#[macro_export]
macro_rules! log_info {
($($arg:tt)*) => {{
#[cfg(debug_assertions)]
if $crate::logging::level_enabled($crate::logging::LEVEL_INFO) {
eprintln!("[INFO] {}", format_args!($($arg)*));
}
$crate::__log_keep_used!($($arg)*);
}};
}
#[macro_export]
macro_rules! log_debug {
($($arg:tt)*) => {{
#[cfg(debug_assertions)]
if $crate::logging::level_enabled($crate::logging::LEVEL_DEBUG) {
eprintln!("[DEBUG] {}", format_args!($($arg)*));
}
$crate::__log_keep_used!($($arg)*);
}};
}
#[macro_export]
macro_rules! log_trace {
($($arg:tt)*) => {{
#[cfg(debug_assertions)]
if $crate::logging::level_enabled($crate::logging::LEVEL_TRACE) {
eprintln!("[TRACE] {}", format_args!($($arg)*));
}
$crate::__log_keep_used!($($arg)*);
}};
}
#[macro_export]
macro_rules! log_warn {
($($arg:tt)*) => {{
if $crate::logging::level_enabled($crate::logging::LEVEL_WARN) {
let _secs = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap_or_default()
.as_secs();
eprintln!("[WARN {:02}:{:02}:{:02}Z] {}", (_secs / 3600) % 24, (_secs / 60) % 60, _secs % 60, format_args!($($arg)*));
}
}};
}
#[macro_export]
macro_rules! log_net_fail {
($($arg:tt)*) => {{
let msg = format!($($arg)*);
if $crate::logging::level_enabled($crate::logging::LEVEL_WARN) {
eprintln!("[WARN] {}", &msg);
}
$crate::logging::persist(&format!(
"[{} WARN] {}",
$crate::logging::timestamp_utc(),
&msg
));
}};
}
#[macro_export]
macro_rules! log_net_info {
($($arg:tt)*) => {{
let msg = format!($($arg)*);
#[cfg(debug_assertions)]
if $crate::logging::level_enabled($crate::logging::LEVEL_INFO) {
eprintln!("[INFO] {}", &msg);
}
$crate::logging::persist(&format!(
"[{} INFO] {}",
$crate::logging::timestamp_utc(),
&msg
));
}};
}