tracing-wasm and init function
This commit is contained in:
parent
42015c27a7
commit
6ab99329b2
@ -20,3 +20,4 @@ wee_alloc = "0.4.5"
|
||||
web-sys = { version = "0.3.56", features = ["HtmlCanvasElement"] }
|
||||
meval = { git = "https://github.com/Titaniumtown/meval-rs.git" }
|
||||
console_error_panic_hook = "0.1.7"
|
||||
tracing-wasm = "0.2.1"
|
||||
20
src/lib.rs
20
src/lib.rs
@ -21,6 +21,23 @@ extern "C" {
|
||||
fn log(s: &str);
|
||||
}
|
||||
|
||||
#[wasm_bindgen(start)]
|
||||
pub fn init() {
|
||||
log("Initializing...");
|
||||
|
||||
// See performance in browser profiler!
|
||||
log("Initializing tracing_wasm...");
|
||||
tracing_wasm::set_as_global_default();
|
||||
log("Initialized tracing_wasm!");
|
||||
|
||||
// Used in order to hook into `panic!()` to log in the browser's console
|
||||
log("Initializing console_error_panic_hook...");
|
||||
panic::set_hook(Box::new(console_error_panic_hook::hook));
|
||||
log("Initialized console_error_panic_hook!");
|
||||
|
||||
log("Finished initializing!");
|
||||
}
|
||||
|
||||
// Manages Chart generation and caching of values
|
||||
#[wasm_bindgen]
|
||||
pub struct ChartManager {
|
||||
@ -54,9 +71,6 @@ impl ChartManager {
|
||||
}
|
||||
}
|
||||
|
||||
// Used in order to hook into `panic!()` to log in the browser's console
|
||||
pub fn init_panic_hook() { panic::set_hook(Box::new(console_error_panic_hook::hook)); }
|
||||
|
||||
// Tests function to make sure it's able to be parsed. Returns the string of the Error produced, or an empty string if it runs successfully.
|
||||
pub fn test_func(function_string: String) -> String {
|
||||
// Factorials do not work, and it would be really difficult to make them work
|
||||
|
||||
@ -27,7 +27,6 @@ export function main() {
|
||||
/** This function is used in `bootstrap.js` to setup imports. */
|
||||
export function setup(WasmChart) {
|
||||
ChartManager = WasmChart;
|
||||
ChartManager.init_panic_hook(); // Allows `panic!()` to log in the browser's console
|
||||
}
|
||||
|
||||
/** Add event listeners. */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user