on master help sign in
Don't rely on LTO to remove logging
commit5b0f773dc844c7d636f48354a895539897aa2ed2 authorNick Fitzgerald <fitzgen@gmail.com> dateThu 14 Feb 2019, 15:37 (8 years ago) parent565a133
7 files changed+81−8
Cargo.lock+1 Cargo.toml+4−5 src/change_list.rs−1 src/events.rs−1 src/lib.rs+3 src/logging.rs+73 src/vdom.rs−1
Cargo.lock+1
@@ -83,6 +83,7 @@ name = "dodrio"
8383version = "0.1.0"
8484dependencies = [
8585 "bumpalo 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
86+ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
8687 "console_log 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
8788 "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
8889 "js-sys 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
Cargo.toml+4−5
@@ -4,16 +4,14 @@ version = "0.1.0"
44authors = ["Nick Fitzgerald <fitzgen@gmail.com>"]
55edition = "2018"
66
7−[features]
8−default = []
9−
107[dependencies]
118bumpalo = "2.1.0"
9+cfg-if = "0.1.6"
1210futures = "0.1.25"
1311wasm-bindgen = "0.2.36"
1412wasm-bindgen-futures = "0.3.13"
1513js-sys = "0.3.13"
16−log = "0.4.6"
14+log = { version = "0.4.6", optional = true }
1715
1816[dependencies.web-sys]
1917version = "0.3.13"
@@ -27,8 +25,9 @@ features = [
2725]
2826
2927[dev-dependencies]
30−wasm-bindgen-test = "0.2.36"
3128console_log = "0.1.2"
29+log = "0.4.6"
30+wasm-bindgen-test = "0.2.36"
3231
3332[dev-dependencies.web-sys]
3433version = "0.3.13"
src/change_list.rs−1
@@ -1,6 +1,5 @@
11use crate::Listener;
22use bumpalo::Bump;
3−use log::*;
43use std::fmt;
54use std::sync::Once;
65use wasm_bindgen::prelude::*;
src/events.rs−1
@@ -1,6 +1,5 @@
11use crate::vdom::{VdomInner, VdomWeak};
22use crate::{Listener, ListenerCallback};
3−use log::*;
43use std::cell::RefCell;
54use std::collections::HashMap;
65use std::fmt;
src/lib.rs+3
@@ -53,6 +53,9 @@
5353// Re-export the `bumpalo` crate.
5454pub use bumpalo;
5555
56+#[macro_use]
57+mod logging;
58+
5659// Only `pub` so that the wasm-bindgen bindings work.
5760#[doc(hidden)]
5861pub mod change_list;
src/logging.rsnew file+73
@@ -0,0 +1,73 @@
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)]
8+ macro_rules! debug {
9+ ( $( $e:expr ),* $(,)* ) => {
10+ if false {
11+ $(
12+ let _ = $e;
13+ )*
14+ }
15+ }
16+ }
17+
18+ #[allow(unused_macros)]
19+ macro_rules! error {
20+ ( $( $e:expr ),* $(,)* ) => {
21+ if false {
22+ $(
23+ let _ = $e;
24+ )*
25+ }
26+ }
27+ }
28+
29+ #[allow(unused_macros)]
30+ macro_rules! info {
31+ ( $( $e:expr ),* $(,)* ) => {
32+ if false {
33+ $(
34+ let _ = $e;
35+ )*
36+ }
37+ }
38+ }
39+
40+ #[allow(unused_macros)]
41+ macro_rules! log {
42+ ( $( $e:expr ),* $(,)* ) => {
43+ if false {
44+ $(
45+ let _ = $e;
46+ )*
47+ }
48+ }
49+ }
50+
51+ #[allow(unused_macros)]
52+ macro_rules! trace {
53+ ( $( $e:expr ),* $(,)* ) => {
54+ if false {
55+ $(
56+ let _ = $e;
57+ )*
58+ }
59+ }
60+ }
61+
62+ #[allow(unused_macros)]
63+ macro_rules! warn {
64+ ( $( $e:expr ),* $(,)* ) => {
65+ if false {
66+ $(
67+ let _ = $e;
68+ )*
69+ }
70+ }
71+ }
72+ }
73+}
src/vdom.rs−1
@@ -4,7 +4,6 @@ use super::RootRender;
44use crate::events::EventsRegistry;
55use bumpalo::Bump;
66use futures::future::Future;
7−use log::*;
87use std::cell::Cell;
98use std::cell::RefCell;
109use std::cmp;