mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-24 12:48:11 +08:00
Add loging implementation for wasm (#56)
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user