Skip to content

Commit

Permalink
Move log macros into stubs file
Browse files Browse the repository at this point in the history
  • Loading branch information
jdub committed Nov 16, 2016
1 parent f26a2d1 commit 19c6dd2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 30 deletions.
42 changes: 12 additions & 30 deletions libbindgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,43 +31,25 @@ extern crate regex;
#[macro_use]
extern crate lazy_static;

#[cfg(feature = "logging")]
#[macro_use]
extern crate log;

#[cfg(not(feature = "logging"))]
#[macro_use]
mod log_stubs;

/*
cfg_if! {
if #[cfg(feature = "logging")] {
#[macro_use]
extern crate log;
} else {
macro_rules! log {
(target: $target:expr, $lvl:expr, $($arg)+) => {
let _ = $target;
let _ = log!($lvl, $($arg)+);
};
($lvl:expr, $($arg:tt)+) => {
let _ = $lvl;
let _ = format_args!($($arg)+);
};
}
macro_rules! error {
(target: $target:expr, $($arg:tt)*) => { log!($target, $($arg)*); };
($($arg:tt)*) => { log!("", $($arg)*); };
}
macro_rules! warn {
(target: $target:expr, $($arg:tt)*) => { log!($target, $($arg)*); };
($($arg:tt)*) => { log!("", $($arg)*); };
}
macro_rules! info {
(target: $target:expr, $($arg:tt)*) => { log!($target, $($arg)*); };
($($arg:tt)*) => { log!("", $($arg)*); };
}
macro_rules! debug {
(target: $target:expr, $($arg:tt)*) => { log!($target, $($arg)*); };
($($arg:tt)*) => { log!("", $($arg)*); };
}
macro_rules! trace {
(target: $target:expr, $($arg:tt)*) => { log!($target, $($arg)*); };
($($arg:tt)*) => { log!("", $($arg)*); };
}
#[macro_use]
mod log_stubs;
}
}
*/

// A macro to declare an internal module for which we *must* provide
// documentation for. If we are building with the "_docs" feature, then the
Expand Down
30 changes: 30 additions & 0 deletions libbindgen/src/log_stubs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
macro_rules! log {
(target: $target:expr, $lvl:expr, $($arg)+) => {
let _ = $target;
let _ = log!($lvl, $($arg)+);
};
($lvl:expr, $($arg:tt)+) => {
let _ = $lvl;
let _ = format_args!($($arg)+);
};
}
macro_rules! error {
(target: $target:expr, $($arg:tt)*) => { log!($target, $($arg)*); };
($($arg:tt)*) => { log!("", $($arg)*); };
}
macro_rules! warn {
(target: $target:expr, $($arg:tt)*) => { log!($target, $($arg)*); };
($($arg:tt)*) => { log!("", $($arg)*); };
}
macro_rules! info {
(target: $target:expr, $($arg:tt)*) => { log!($target, $($arg)*); };
($($arg:tt)*) => { log!("", $($arg)*); };
}
macro_rules! debug {
(target: $target:expr, $($arg:tt)*) => { log!($target, $($arg)*); };
($($arg:tt)*) => { log!("", $($arg)*); };
}
macro_rules! trace {
(target: $target:expr, $($arg:tt)*) => { log!($target, $($arg)*); };
($($arg:tt)*) => { log!("", $($arg)*); };
}

0 comments on commit 19c6dd2

Please sign in to comment.