Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/worldsender/tracing-web
A tracing subscriber for the web
https://github.com/worldsender/tracing-web
debugging-tool logging webassembly
Last synced: 3 months ago
JSON representation
A tracing subscriber for the web
- Host: GitHub
- URL: https://github.com/worldsender/tracing-web
- Owner: WorldSEnder
- License: apache-2.0
- Created: 2022-08-18T23:40:33.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-11-30T09:43:32.000Z (about 1 year ago)
- Last Synced: 2024-10-12T23:44:20.039Z (4 months ago)
- Topics: debugging-tool, logging, webassembly
- Language: Rust
- Homepage: https://crates.io/crates/tracing-web
- Size: 24.4 KB
- Stars: 17
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
## tracing-web
A [`tracing`] compatible subscriber layer for web platforms.
[![Crates.io][crates-badge]][crates-url]
[![Documentation][docs-badge]][docs-url]
[![MIT licensed][mit-badge]][mit-url]
[![Apache licensed][apache-badge]][apache-url][Documentation][docs-url]
[`tracing`]: https://crates.io/crates/tracing
[crates-badge]: https://img.shields.io/crates/v/tracing-web.svg
[crates-url]: https://crates.io/crates/tracing-web
[docs-badge]: https://docs.rs/tracing-web/badge.svg
[docs-url]: https://docs.rs/tracing-web
[mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg
[mit-url]: LICENSE-MIT
[apache-badge]: https://img.shields.io/badge/license-Apache-blue.svg
[apache-url]: LICENSE-APACHE# 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```rust
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 eventstodo!("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`.```toml
time = { version = "0.3", features = ["wasm-bindgen"] }
```[`tracing-subscriber`]: https://crates.io/crates/tracing-subscriber
[Performance API]: https://developer.mozilla.org/en-US/docs/Web/API/Performance
[`UtcTime`]: https://docs.rs/tracing-subscriber/0.3.18/tracing_subscriber/fmt/time/struct.UtcTime.html# License
This project is dual licensed under the [MIT license] and the [Apache license].
[MIT license]: LICENSE-MIT
[Apache license]: LICENSE-APACHE