tracing-wasm

Crates.iotracing-wasm
lib.rstracing-wasm
version0.2.1
sourcesrc
created_at2020-07-11 13:02:23.078828
updated_at2021-11-07 17:52:27.786052
descriptiontracing subscriber for browser WASM
homepage
repositoryhttps://github.com/storyai/tracing-wasm
max_upload_size
id264016
size31,447
Cole Lawrence (colelawrence)

documentation

README

tracing-wasm

Leverage performance profiling with your browser tools with the tracing crate.

Crates.io Documentation MIT licensed APACHE licensed

Screenshot of performance reported using the tracing-wasm Subscriber

Note: tracing_wasm uses the global JavaScript console and performance objects. It will not work in environments where one or both of these are not available, such as Node.js or Cloudflare Workers.

Usage

For the simplest out of the box set-up, you can simply set tracing_wasm as your default tracing Subscriber in wasm_bindgen(start)

We have this declared in our ./src/lib.rs

#[wasm_bindgen(start)]
pub fn start() -> Result<(), JsValue> {
    // print pretty errors in wasm https://github.com/rustwasm/console_error_panic_hook
    // This is not needed for tracing_wasm to work, but it is a common tool for getting proper error line numbers for panics.
    console_error_panic_hook::set_once();

    // Add this line:
    tracing_wasm::set_as_global_default();

    Ok(())
}
Commit count: 31

cargo fmt