on master help sign in
Fix logging macros for allowing the log feature to be on or off
d99edeeNick Fitzgerald
src/lib.rs+9−2
@@ -53,8 +53,15 @@
53// Re-export the `bumpalo` crate.
53// Re-export the `bumpalo` crate.
54pub use bumpalo;
54pub use bumpalo;
55
55
56+cfg_if::cfg_if! {
57+ if #[cfg(feature = "log")] {
58+ #[macro_use]
59+ extern crate log;
60+ } else {
56−#[macro_use]
61+ #[macro_use]
57−mod logging;
62+ mod logging;
63+ }
64+}
58
65
59// Only `pub` so that the wasm-bindgen bindings work.
66// Only `pub` so that the wasm-bindgen bindings work.
60#[doc(hidden)]
67#[doc(hidden)]
src/logging.rs+52−60
@@ -1,73 +1,65 @@
1−use cfg_if::cfg_if;
2−
3−cfg_if! {
4− if #[cfg(feature = "log")] {
5− pub use log::*;
6− } else {
7− #[allow(unused_macros)]
1+#[allow(unused_macros)]
8− macro_rules! debug {
2+macro_rules! debug {
9− ( $( $e:expr ),* $(,)* ) => {
3+ ( $( $e:expr ),* $(,)* ) => {
10− if false {
4+ if false {
11− $(
5+ $(
12− let _ = $e;
6+ let _ = $e;
13− )*
7+ )*
14− }
15− }
16 }
8 }
9+ }
10+}
17
11
18− #[allow(unused_macros)]
12+#[allow(unused_macros)]
19− macro_rules! error {
13+macro_rules! error {
20− ( $( $e:expr ),* $(,)* ) => {
14+ ( $( $e:expr ),* $(,)* ) => {
21− if false {
15+ if false {
22− $(
16+ $(
23− let _ = $e;
17+ let _ = $e;
24− )*
18+ )*
25− }
26− }
27 }
19 }
20+ }
21+}
28
22
29− #[allow(unused_macros)]
23+#[allow(unused_macros)]
30− macro_rules! info {
24+macro_rules! info {
31− ( $( $e:expr ),* $(,)* ) => {
25+ ( $( $e:expr ),* $(,)* ) => {
32− if false {
26+ if false {
33− $(
27+ $(
34− let _ = $e;
28+ let _ = $e;
35− )*
29+ )*
36− }
37− }
38 }
30 }
31+ }
32+}
39
33
40− #[allow(unused_macros)]
34+#[allow(unused_macros)]
41− macro_rules! log {
35+macro_rules! log {
42− ( $( $e:expr ),* $(,)* ) => {
36+ ( $( $e:expr ),* $(,)* ) => {
43− if false {
37+ if false {
44− $(
38+ $(
45− let _ = $e;
39+ let _ = $e;
46− )*
40+ )*
47− }
48− }
49 }
41 }
42+ }
43+}
50
44
51− #[allow(unused_macros)]
45+#[allow(unused_macros)]
52− macro_rules! trace {
46+macro_rules! trace {
53− ( $( $e:expr ),* $(,)* ) => {
47+ ( $( $e:expr ),* $(,)* ) => {
54− if false {
48+ if false {
55− $(
49+ $(
56− let _ = $e;
50+ let _ = $e;
57− )*
51+ )*
58− }
59− }
60 }
52 }
53+ }
54+}
61
55
62− #[allow(unused_macros)]
56+#[allow(unused_macros)]
63− macro_rules! warn {
57+macro_rules! warn {
64− ( $( $e:expr ),* $(,)* ) => {
58+ ( $( $e:expr ),* $(,)* ) => {
65− if false {
59+ if false {
66− $(
60+ $(
67− let _ = $e;
61+ let _ = $e;
68− )*
62+ )*
69− }
70− }
71 }
63 }
72 }
64 }
73}
65}