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

[SM-1384] Fix panic on re-registering logger | WASM #935

Merged
merged 6 commits into from
Sep 12, 2024
Merged
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
9 changes: 4 additions & 5 deletions crates/bitwarden-wasm/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use argon2::{Algorithm, Argon2, Params, Version};
use bitwarden_json::client::Client as JsonClient;
use js_sys::Promise;
use log::Level;
use log::{set_max_level, Level};
use wasm_bindgen::prelude::*;
use wasm_bindgen_futures::future_to_promise;

Expand Down Expand Up @@ -37,10 +37,9 @@
#[wasm_bindgen(constructor)]
pub fn new(settings_input: Option<String>, log_level: Option<LogLevel>) -> Self {
console_error_panic_hook::set_once();
if let Err(e) =
console_log::init_with_level(convert_level(log_level.unwrap_or(LogLevel::Info)))
{
panic!("failed to initialize logger: {:?}", e);
let log_level = convert_level(log_level.unwrap_or(LogLevel::Info));
if let Err(_e) = console_log::init_with_level(log_level) {
set_max_level(log_level.to_level_filter())

Check warning on line 42 in crates/bitwarden-wasm/src/client.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-wasm/src/client.rs#L40-L42

Added lines #L40 - L42 were not covered by tests
}

Self(Rc::new(bitwarden_json::client::Client::new(settings_input)))
Expand Down
Loading