Skip to content

Commit

Permalink
Update macros.rs
Browse files Browse the repository at this point in the history
Revert "Update macros.rs"

This reverts commit 3c886b2.

Update macros.rs
  • Loading branch information
droideck committed Jan 10, 2025
1 parent 986cb5c commit 8a06e5b
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/slapi_r_plugin/src/macros.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
#[macro_export]
#[cfg(not(feature = "test_log_direct"))]
macro_rules! log_error {
($level:expr, $($arg:tt)*) => ({
macro_rules! log_error_ext {
($level:expr, $source:expr, $($arg:tt)*) => ({
use std::fmt;
match log_error(
$level,
format!("{}:{}", file!(), line!()),
$source.to_string(),
format!("{}\n", fmt::format(format_args!($($arg)*)))
) {
Ok(_) => {},
Err(e) => {
eprintln!("A logging error occured {}, {} -> {:?}", file!(), line!(), e);
eprintln!("A logging error occurred {}, {} -> {:?}", file!(), line!(), e);
}
};
})
}

#[macro_export]
#[cfg(feature = "test_log_direct")]
macro_rules! log_error_ext {
($level:expr, $source:expr, $($arg:tt)*) => ({
use std::fmt;
eprintln!("{} -> {}", $source, fmt::format(format_args!($($arg)*)));
})
}

#[macro_export]
macro_rules! log_error {
($level:expr, $($arg:tt)*) => ({
use std::fmt;
eprintln!("{}:{} -> {}", file!(), line!(), fmt::format(format_args!($($arg)*)));
log_error_ext!($level, format!("{}:{}", file!(), line!()), $($arg)*)
})
}

#[macro_export]
macro_rules! log_error_fn {
($level:expr, $funcname:expr, $($arg:tt)*) => ({
log_error_ext!($level, $funcname, $($arg)*)
})
}

Expand Down

0 comments on commit 8a06e5b

Please sign in to comment.