Skip to content

Commit 64abb06

Browse files
committed
Fix logging macros
1 parent 7f34c4a commit 64abb06

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

src/lib.rs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,35 @@ extern crate alloc;
6060
use getrandom_package as getrandom;
6161

6262
#[allow(unused)]
63-
#[cfg(not(feature = "log"))] macro_rules! trace { ($($x:tt)*) => () }
63+
macro_rules! trace { ($($x:tt)*) => (
64+
#[cfg(feature = "log")] {
65+
log::trace!($($x)*)
66+
}
67+
) }
6468
#[allow(unused)]
65-
#[cfg(not(feature = "log"))] macro_rules! debug { ($($x:tt)*) => () }
69+
macro_rules! debug { ($($x:tt)*) => (
70+
#[cfg(feature = "log")] {
71+
log::debug!($($x)*)
72+
}
73+
) }
6674
#[allow(unused)]
67-
#[cfg(not(feature = "log"))] macro_rules! info { ($($x:tt)*) => () }
75+
macro_rules! info { ($($x:tt)*) => (
76+
#[cfg(feature = "log")] {
77+
log::info!($($x)*)
78+
}
79+
) }
6880
#[allow(unused)]
69-
#[cfg(not(feature = "log"))] macro_rules! warn { ($($x:tt)*) => () }
81+
macro_rules! warn { ($($x:tt)*) => (
82+
#[cfg(feature = "log")] {
83+
log::warn!($($x)*)
84+
}
85+
) }
7086
#[allow(unused)]
71-
#[cfg(not(feature = "log"))] macro_rules! error { ($($x:tt)*) => () }
72-
87+
macro_rules! error { ($($x:tt)*) => (
88+
#[cfg(feature = "log")] {
89+
log::error!($($x)*)
90+
}
91+
) }
7392

7493
// Re-exports from rand_core
7594
pub use rand_core::{RngCore, CryptoRng, SeedableRng, Error};

0 commit comments

Comments
 (0)