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

tracing-subscriber-wasm

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

1 unstable release

0.1.0 Jan 31, 2023

#637 in WebAssembly

Download history 671/week @ 2024-03-13 577/week @ 2024-03-20 361/week @ 2024-03-27 590/week @ 2024-04-03 652/week @ 2024-04-10 531/week @ 2024-04-17 477/week @ 2024-04-24 1043/week @ 2024-05-01 888/week @ 2024-05-08 795/week @ 2024-05-15 949/week @ 2024-05-22 1015/week @ 2024-05-29 889/week @ 2024-06-05 974/week @ 2024-06-12 726/week @ 2024-06-19 1190/week @ 2024-06-26

3,929 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