Add loging implementation for wasm (#56)

This commit is contained in:
TrueDoctor
2021-03-30 18:48:32 +02:00
committed by GitHub
parent b5cd8327dd
commit 593572a4e8
5 changed files with 43 additions and 1 deletions
+5 -1
View File
@@ -4,16 +4,20 @@ pub mod utils;
pub mod window;
pub mod wrappers;
use editor_core::{events::Response, Callback, Editor};
use editor_core::{events::Response, Editor};
use std::cell::RefCell;
use utils::WasmLog;
use wasm_bindgen::prelude::*;
// the thread_local macro provides a way to initialize static variables with non-constant functions
thread_local! { pub static EDITOR_STATE: RefCell<Editor> = RefCell::new(Editor::new(Box::new(handle_response))) }
static LOGGER: WasmLog = WasmLog;
#[wasm_bindgen(start)]
pub fn init() {
utils::set_panic_hook();
log::set_logger(&LOGGER).expect("Failed to set logger");
log::set_max_level(log::LevelFilter::Debug);
}
fn handle_response(response: Response) {