wasm-tracing

Crates.iowasm-tracing
lib.rswasm-tracing
version0.2.1
sourcesrc
created_at2024-09-04 16:09:04.730873
updated_at2024-09-04 16:55:44.777284
descriptionTracing subscriber for WebAssembly. Maintained fork of tracing-wasm.
homepage
repositoryhttps://github.com/dsgallups/wasm-tracing
max_upload_size
id1363491
size22,623
Daniel Gallups (dsgallups)

documentation

README

wasm-tracing

A maintained fork of tracing-wasm that is compatible with the latest tracing and wasm-bindgen versions.

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

Crates.io Documentation MIT licensed APACHE licensed

Note: wasm_tracing 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 wasm_tracing 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:
    wasm_tracing::set_as_global_default();

    Ok(())
}
Commit count: 0

cargo fmt