From b7011027689008829b13dd4f5783ff2b6879acff Mon Sep 17 00:00:00 2001 From: Ben Sully Date: Wed, 18 Dec 2024 10:30:00 +0000 Subject: [PATCH] deps: bump wasm-tracing to 1.0 The 1.0 update improves the APIs and includes a helpful change to omit the origin (line number, file name) from the logs (https://github.com/dsgallups/wasm-tracing/pull/11). --- js/augurs-core-js/Cargo.toml | 2 +- js/augurs-core-js/src/logging.rs | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/js/augurs-core-js/Cargo.toml b/js/augurs-core-js/Cargo.toml index a299626e..c7e24950 100644 --- a/js/augurs-core-js/Cargo.toml +++ b/js/augurs-core-js/Cargo.toml @@ -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'] diff --git a/js/augurs-core-js/src/logging.rs b/js/augurs-core-js/src/logging.rs index 617a4afe..92ef5c7b 100644 --- a/js/augurs-core-js/src/logging.rs +++ b/js/augurs-core-js/src/logging.rs @@ -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. /// @@ -102,16 +102,17 @@ pub struct LogConfig { #[wasm_bindgen(js_name = "initLogging")] pub fn init_logging(config: Option) -> 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")) }