restructuring and better debug

This commit is contained in:
Simon Gardling
2022-02-28 10:04:22 -05:00
parent f5ce5b9f2f
commit 0520904e7e
6 changed files with 40 additions and 15 deletions

View File

@@ -21,15 +21,25 @@ extern "C" {
fn log(s: &str);
}
#[cfg(target_arch = "wasm32")]
#[cfg(debug_assertions)]
fn init_tracing_wasm() {
log("Initializing tracing_wasm...");
tracing_wasm::set_as_global_default();
log("Initialized tracing_wasm!");
}
#[cfg(target_arch = "wasm32")]
#[cfg(not(debug_assertions))]
fn init_tracing_wasm() { }
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen]
pub fn start(canvas_id: &str) -> Result<(), wasm_bindgen::JsValue> {
log("Initializing...");
// See performance in browser profiler!
log("Initializing tracing_wasm...");
tracing_wasm::set_as_global_default();
log("Initialized tracing_wasm!");
init_tracing_wasm();
// Used in order to hook into `panic!()` to log in the browser's console
log("Initializing console_error_panic_hook...");