#web #wasm #tracing #log

tracing-web

A tracing compatible subscriber layer for web platforms

3 releases

0.1.2 Aug 19, 2022
0.1.1 Aug 19, 2022
0.1.0 Aug 19, 2022

#293 in WebAssembly

Download history 40/week @ 2022-12-04 42/week @ 2022-12-11 80/week @ 2022-12-18 30/week @ 2022-12-25 28/week @ 2023-01-01 34/week @ 2023-01-08 308/week @ 2023-01-15 2757/week @ 2023-01-22 3960/week @ 2023-01-29 3457/week @ 2023-02-05 3725/week @ 2023-02-12 4167/week @ 2023-02-19 3869/week @ 2023-02-26 4727/week @ 2023-03-05 6056/week @ 2023-03-12 5931/week @ 2023-03-19

21,031 downloads per month
Used in 2 crates (via stellation-frontend)

MIT/Apache

19KB
322 lines

tracing-web

A tracing compatible subscriber layer for web platforms.

Crates.io Documentation MIT licensed Apache licensed

Documentation

Overview

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::{MakeConsoleWriter, performance_layer};
use tracing_subscriber::fmt::format::Pretty;
use tracing_subscriber::fmt::time::UtcTime;
use tracing_subscriber::prelude::*;

fn main() {
    let fmt_layer = tracing_subscriber::fmt::layer()
        .with_ansi(false) // Only partially supported across browsers
        .with_timer(UtcTime::rfc_3339()) // std::time is not available in browsers
        .with_writer(MakeConsoleWriter); // 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");
}

License

This project is dual licensed under the MIT license and the Apache license.

Dependencies

~9.5MB
~184K SLoC