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

tracing-subscriber-wasm

使用wasm-bindgen将日志写入控制台的tracing-subscriber writer

1个不稳定版本

0.1.0 2023年1月31日

#637WebAssembly

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 每月下载量
2 crate 中使用

MIT 许可证

9KB
96

tracing-subscriber-wasm

一个允许在浏览器或NodeJS中直接使用tracing_subscriberMakeWriter实现。

MakeConsoleWriter允许将任意跟踪事件映射到任何其他控制台详细程度。在构建writer时检查MakeConsoleWriter::map_trace_level_to和类似方法。

重要提示

在我的测试中,如果您在订阅者构建器上不调用.without_time,则会抛出运行时异常。

示例

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();

许可证:MIT


lib.rs:

一个允许在浏览器或NodeJS中直接使用tracing_subscriberMakeWriter实现。

MakeConsoleWriter允许将任意跟踪事件映射到任何其他控制台详细程度。在构建writer时检查MakeConsoleWriter::map_trace_level_to和类似方法。

重要提示

在我的测试中,如果您在订阅者构建器上不调用.without_time,则会抛出运行时异常。

示例

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();

依赖项

~2MB
~23K SLoC