Skip to content

Commit

Permalink
deps: bump wasm-tracing to 1.0
Browse files Browse the repository at this point in the history
The 1.0 update improves the APIs and includes a helpful change to
omit the origin (line number, file name) from the logs
(dsgallups/wasm-tracing#11).
  • Loading branch information
sd2k committed Dec 18, 2024
1 parent 0e56162 commit b701102
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion js/augurs-core-js/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ tracing.workspace = true
tracing-subscriber = { workspace = true, features = ["registry"], default-features = false }
tsify-next.workspace = true
wasm-bindgen.workspace = true
wasm-tracing = { version = "0.2.1", optional = true }
wasm-tracing = { version = "1.0.1", optional = true }

[package.metadata.wasm-pack.profile.release]
# previously had just ['-O4']
Expand Down
23 changes: 12 additions & 11 deletions js/augurs-core-js/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use serde::Deserialize;
use tracing_subscriber::{layer::SubscriberExt, Registry};
use tsify_next::Tsify;
use wasm_bindgen::prelude::*;
use wasm_tracing::WASMLayer;
use wasm_tracing::{ConsoleConfig, WasmLayer, WasmLayerConfig};

/// The maximum log level to emit.
///
Expand Down Expand Up @@ -102,16 +102,17 @@ pub struct LogConfig {
#[wasm_bindgen(js_name = "initLogging")]
pub fn init_logging(config: Option<LogConfig>) -> Result<(), JsError> {
let config = config.unwrap_or_default();
let config = wasm_tracing::WASMLayerConfigBuilder::new()
.set_show_fields(config.show_detailed_fields)
.set_report_logs_in_timings(matches!(config.target, LogTarget::Performance))
.set_console_config(if config.color {
wasm_tracing::ConsoleConfig::ReportWithConsoleColor
let config = WasmLayerConfig {
report_logs_in_timings: matches!(config.target, LogTarget::Performance),
show_fields: config.show_detailed_fields,
console: if config.color {
ConsoleConfig::ReportWithConsoleColor
} else {
wasm_tracing::ConsoleConfig::ReportWithoutConsoleColor
})
.set_max_level(config.max_level.into())
.build();
tracing::subscriber::set_global_default(Registry::default().with(WASMLayer::new(config)))
ConsoleConfig::ReportWithoutConsoleColor
},
max_level: config.max_level.into(),
show_origin: false,
};
tracing::subscriber::set_global_default(Registry::default().with(WasmLayer::new(config)))
.map_err(|_| JsError::new("logging already initialized"))
}

0 comments on commit b701102

Please sign in to comment.