Skip to content

Commit

Permalink
tech(fmt): use wasm logging (#4919)
Browse files Browse the repository at this point in the history
* Uses wasm-logger feature
update script for usage w/ language-tools now uses said feature
  • Loading branch information
Druue committed Jun 13, 2024
1 parent 03f1367 commit e9ac668
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion prisma-schema-wasm/scripts/update-schema-wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ language_tools_node="$language_tools_server/node_modules/@prisma/prisma-schema-w

## Script
printf '%s\n' "Starting build :: prisma-schema-wasm"
cargo build --release --target=wasm32-unknown-unknown --manifest-path=$prisma_schema_wasm_dir/Cargo.toml
cargo build --features wasm-logger --release --target=wasm32-unknown-unknown --manifest-path=$prisma_schema_wasm_dir/Cargo.toml

printf '%s\n' "Generating node module"
out=$prisma_schema_wasm_dir/nodejs $prisma_schema_wasm_dir/scripts/install.sh
Expand Down
9 changes: 3 additions & 6 deletions prisma-schema-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ fn register_panic_hook() {
static SET_HOOK: Once = Once::new();

SET_HOOK.call_once(|| {
#[cfg(feature = "wasm-logger")]
wasm_logger::init(wasm_logger::Config::default());

panic::set_hook(Box::new(|info| {
let message = &info.to_string();
prisma_set_wasm_panic_message(message);
Expand Down Expand Up @@ -110,9 +113,3 @@ pub fn debug_panic() {
register_panic_hook();
panic!("This is the panic triggered by `prisma_fmt::debug_panic()`");
}

#[cfg(feature = "wasm_logger")]
#[wasm_bindgen]
pub fn enable_logs() {
wasm_logger::init(wasm_logger::Config::default());
}

0 comments on commit e9ac668

Please sign in to comment.