From c766cea1f05ceebc6acff38b26ba36de56e39c93 Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Thu, 21 Mar 2024 15:22:31 -0400 Subject: [PATCH 1/2] SM-1147: Try to init logger and fail safely rather than the panic that occurs. --- crates/bitwarden-py/src/client.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bitwarden-py/src/client.rs b/crates/bitwarden-py/src/client.rs index f1d282b41..8136a6b32 100644 --- a/crates/bitwarden-py/src/client.rs +++ b/crates/bitwarden-py/src/client.rs @@ -8,7 +8,7 @@ pub struct BitwardenClient(JsonClient); impl BitwardenClient { #[new] pub fn new(settings_string: Option) -> Self { - pyo3_log::init(); + _ = pyo3_log::try_init(); Self(JsonClient::new(settings_string)) } From 4c5b926f1a59ada1123e58922eb5721dbc979d72 Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Fri, 22 Mar 2024 11:55:13 -0400 Subject: [PATCH 2/2] SM-1147: Add comment for consistency across crates --- crates/bitwarden-py/src/client.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/bitwarden-py/src/client.rs b/crates/bitwarden-py/src/client.rs index 8136a6b32..c3ea62444 100644 --- a/crates/bitwarden-py/src/client.rs +++ b/crates/bitwarden-py/src/client.rs @@ -8,7 +8,10 @@ pub struct BitwardenClient(JsonClient); impl BitwardenClient { #[new] pub fn new(settings_string: Option) -> Self { - _ = pyo3_log::try_init(); + // This will only fail if another logger was already initialized, so we can ignore the + // result + let _ = pyo3_log::try_init(); + Self(JsonClient::new(settings_string)) }