#tracing-subscriber #console #writer #debugging #profiling

tracing-subscriber-wasm

A tracing-subscriber writer that writes to the console using wasm-bindgen

1 unstable release

0.1.0 Jan 31, 2023

#943 in WebAssembly

Download history 1271/week @ 2023-11-20 1178/week @ 2023-11-27 1214/week @ 2023-12-04 1045/week @ 2023-12-11 646/week @ 2023-12-18 293/week @ 2023-12-25 1110/week @ 2024-01-01 1537/week @ 2024-01-08 1215/week @ 2024-01-15 1663/week @ 2024-01-22 992/week @ 2024-01-29 332/week @ 2024-02-05 415/week @ 2024-02-12 355/week @ 2024-02-19 446/week @ 2024-02-26 552/week @ 2024-03-04

1,771 downloads per month
Used in 2 crates

MIT license

9KB
96 lines

tracing-subscriber-wasm

A MakeWriter implementation to allow directly using tracing_subscriber in the browser or with NodeJS.

The MakeConsoleWriter allows mapping arbitrary trace events to any other console verbosity level. Check out the MakeConsoleWriter::map_trace_level_to and similar methods when building the writer.

Important Note

In my testing, if you don't call .without_time on the subscriber builder, a runtime exception will be raised.

Example

use tracing_subscriber::fmt;
use tracing_subscriber_wasm::MakeConsoleWriter;

fmt()
  .with_writer(
    // To avoide trace events in the browser from showing their
    // JS backtrace, which is very annoying, in my opinion
    MakeConsoleWriter::default().map_trace_level_to(tracing::Level::DEBUG),
  )
  // For some reason, if we don't do this in the browser, we get
  // a runtime error.
  .without_time()
  .init();

License: MIT


lib.rs:

A MakeWriter implementation to allow directly using tracing_subscriber in the browser or with NodeJS.

The MakeConsoleWriter allows mapping arbitrary trace events to any other console verbosity level. Check out the MakeConsoleWriter::map_trace_level_to and similar methods when building the writer.

Important Note

In my testing, if you don't call .without_time on the subscriber builder, a runtime exception will be raised.

Example

use tracing_subscriber::fmt;
use tracing_subscriber_wasm::MakeConsoleWriter;

fmt()
  .with_writer(
    // To avoide trace events in the browser from showing their
    // JS backtrace, which is very annoying, in my opinion
    MakeConsoleWriter::default().map_trace_level_to(tracing::Level::DEBUG),
  )
  // For some reason, if we don't do this in the browser, we get
  // a runtime error.
  .without_time()
  .init();

Dependencies

~2MB
~23K SLoC