Skip to content

Commit

Permalink
Update macros.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
droideck committed Jan 10, 2025
1 parent 986cb5c commit 3c886b2
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions src/slapi_r_plugin/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,37 @@
macro_rules! log_error {
($level:expr, $($arg:tt)*) => ({
use std::fmt;
match log_error(
match $crate::log_error(
$level,
String::from("389DS"),
format!("{}\n", fmt::format(format_args!($($arg)*)))
) {
Ok(_) => {},
Err(e) => {
eprintln!("Logging error occurred -> {:?}", e);
}
};
})
}

#[macro_export]
#[cfg(not(feature = "test_log_direct"))]
macro_rules! log_error_debug {
($level:expr, $($arg:tt)*) => ({
use std::fmt;
match $crate::log_error(
$level,
format!("{}:{}", file!(), line!()),
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
);
}
};
})
Expand All @@ -19,6 +42,15 @@ macro_rules! log_error {
#[macro_export]
#[cfg(feature = "test_log_direct")]
macro_rules! log_error {
($level:expr, $($arg:tt)*) => ({
use std::fmt;
eprintln!("{}", fmt::format(format_args!($($arg)*)));
})
}

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

0 comments on commit 3c886b2

Please sign in to comment.