Skip to content

Commit d46250a

Browse files
authored
chore: rewrite rust debug (#85)
1 parent 2497e0c commit d46250a

3 files changed

Lines changed: 13 additions & 12 deletions

File tree

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rs_lib/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ crate-type = ["cdylib"]
1010
anyhow.workspace = true
1111
deno_config.workspace = true
1212
deno_path_util.workspace = true
13+
web-sys = { version = "=0.3.77", features = ["console"] }
1314
js-sys.workspace = true
1415
sys_traits = { workspace = true, features = ["real"] }
1516
serde.workspace = true

rs_lib/src/lib.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,12 @@ use sys_traits::FsMetadata;
1010
use url::Url;
1111
use wasm_bindgen::prelude::*;
1212

13-
#[cfg(target_arch = "wasm32")]
14-
#[wasm_bindgen]
15-
extern "C" {
16-
#[wasm_bindgen(js_namespace = console, js_name = log)]
17-
fn console_log(s: &str);
18-
}
19-
20-
#[cfg(target_arch = "wasm32")]
2113
fn debug_log(debug: bool, msg: &str) {
2214
if debug {
23-
console_log(&format!("[rs_lib] {}", msg));
15+
web_sys::console::log_1(&serde_wasm_bindgen::to_value(&format!("[rs_lib] {}", msg)).unwrap());
2416
}
2517
}
2618

27-
#[cfg(not(target_arch = "wasm32"))]
28-
fn debug_log(_debug: bool, _msg: &str) {}
29-
3019
#[derive(Serialize)]
3120
pub struct ConfigLookup {
3221
pub path: Option<String>,

0 commit comments

Comments
 (0)