Expand description
emit_web
Use emit
in WebAssembly applications targeting NodeJS and the browser.
emit
itself and some emitters, like emit_otlp
support WebAssembly directly. This library includes support for emitting events to the Console API. It also has alternative clocks and randomness using different web features. These aren’t required for configuration, but can be used to more directly control the JavaScript APIs emit
makes use of.
§Getting started
First, add emit
and emit_web
to your Cargo.toml
:
[dependencies.emit]
version = "1"
[dependencies.emit_web]
version = "0.2.1"
Next, configure emit
to use web APIs in its runtime:
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn setup() {
let _ = emit::setup()
.emit_to(emit_web::console())
.try_init();
}
The name of this setup
function doesn’t matter, you’ll just need to call it somewhere early in your application.
Structs§
- Console
Emitter - An emitter based on the Console API.
- Crypto
Rng - An RNG based on the Crypto API.
- Date
Clock - A clock based on the Date type.
- Performance
Clock - A clock based on the Performance API.
Functions§
- console
- An emitter based on the Console API.
- crypto_
rng - A source of randomness based on the Crypto API.
- date_
clock - A clock based on the Date type.
- performance_
clock - A clock based on the Performance API.