Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tech(fmt): use wasm logging #4919

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}
Loading