| Crates.io | tracing-web |
| lib.rs | tracing-web |
| version | 0.1.3 |
| created_at | 2022-08-19 00:13:42.288016+00 |
| updated_at | 2023-11-30 09:47:16.62396+00 |
| description | A tracing compatible subscriber layer for web platforms. |
| homepage | |
| repository | https://github.com/WorldSEnder/tracing-web |
| max_upload_size | |
| id | 648432 |
| size | 39,836 |
A tracing compatible subscriber layer for web platforms.
tracing-web can be used in conjunction with the tracing-subscriber crate to quickly install a
subscriber that emits messages to the dev-tools console, and events to the Performance API. An example
configuration can look like
use tracing_web::{MakeWebConsoleWriter, performance_layer};
use tracing_subscriber::fmt::format::Pretty;
use tracing_subscriber::prelude::*;
fn main() {
let fmt_layer = tracing_subscriber::fmt::layer()
.with_ansi(false) // Only partially supported across browsers
.without_time() // std::time is not available in browsers, see note below
.with_writer(MakeWebConsoleWriter::new()); // write events to the console
let perf_layer = performance_layer()
.with_details_from_fields(Pretty::default());
tracing_subscriber::registry()
.with(fmt_layer)
.with(perf_layer)
.init(); // Install these as subscribers to tracing events
todo!("write your awesome application");
}
Note: You can alternatively use .with_timer(UtcTime::rfc_3339()) with UtcTime on web targets if you enable
the wasm-bindgen feature of the time crate, for example by adding the following to your Cargo.toml.
time = { version = "0.3", features = ["wasm-bindgen"] }
This project is dual licensed under the MIT license and the Apache license.