Skip to content

Commit 063b63d

Browse files
committed
Replace log with tracing for ios and android uniffi
1 parent 4921d8a commit 063b63d

File tree

4 files changed

+144
-108
lines changed

4 files changed

+144
-108
lines changed

Cargo.lock

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

crates/bitwarden-uniffi/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,22 @@ bitwarden-state = { workspace = true, features = ["uniffi"] }
3434
bitwarden-uniffi-error = { workspace = true }
3535
bitwarden-vault = { workspace = true, features = ["uniffi"] }
3636
chrono = { workspace = true, features = ["std"] }
37-
env_logger = "0.11.1"
38-
log = { workspace = true }
3937
thiserror = { workspace = true }
38+
tracing = { workspace = true }
39+
tracing-subscriber = { workspace = true }
4040
uniffi = { workspace = true }
4141
uuid = { workspace = true }
4242

4343
[target.'cfg(target_os = "android")'.dependencies]
44-
android_logger = "0.15"
44+
tracing-android = "0.2.0"
4545

4646
# The use of rustls-platform-verifier requires some extra support to communicate with the Android platform
4747
jni = ">=0.21, <0.22"
4848
libloading = ">=0.8.1, <0.9"
4949
rustls-platform-verifier = "0.6.0"
5050

5151
[target.'cfg(target_os = "ios")'.dependencies]
52-
oslog = "0.2.0"
52+
tracing-oslog = "0.3.0"
5353

5454
[build-dependencies]
5555
uniffi = { workspace = true, features = ["build"] }

crates/bitwarden-uniffi/src/android_support.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::{error::Error, sync::OnceLock};
22

33
use jni::sys::{JavaVM, jint, jsize};
4+
use tracing::{error, info};
45

56
pub static JAVA_VM: OnceLock<jni::JavaVM> = OnceLock::new();
67

@@ -9,7 +10,7 @@ pub static JAVA_VM: OnceLock<jni::JavaVM> = OnceLock::new();
910
#[allow(non_snake_case)]
1011
#[unsafe(no_mangle)]
1112
pub extern "system" fn JNI_OnLoad(vm_ptr: jni::JavaVM, _reserved: *mut std::ffi::c_void) -> jint {
12-
log::info!("JNI_OnLoad initializing");
13+
info!("JNI_OnLoad initializing");
1314
JAVA_VM.get_or_init(|| vm_ptr);
1415
jni::sys::JNI_VERSION_1_6
1516
}
@@ -18,25 +19,25 @@ pub fn init() {
1819
fn init_inner() -> Result<(), Box<dyn Error>> {
1920
let jvm = match JAVA_VM.get() {
2021
Some(jvm) => {
21-
log::info!("JavaVM already initialized");
22+
info!("JavaVM already initialized");
2223
jvm
2324
}
2425
None => {
25-
log::info!("JavaVM not initialized, initializing now");
26+
info!("JavaVM not initialized, initializing now");
2627
let jvm = java_vm()?;
2728
JAVA_VM.get_or_init(|| jvm)
2829
}
2930
};
3031

3132
let mut env = jvm.attach_current_thread_permanently()?;
32-
log::info!("Initializing Android verifier");
33+
info!("Initializing Android verifier");
3334
init_verifier(&mut env)?;
34-
log::info!("SDK Android support initialized");
35+
info!("SDK Android support initialized");
3536
Ok(())
3637
}
3738

38-
if let Err(e) = init_inner() {
39-
log::error!("Failed to initialize Android support: {:#?}", e);
39+
if let Err(error) = init_inner() {
40+
error!(%error, "Failed to initialize Android support");
4041
}
4142
}
4243

0 commit comments

Comments
 (0)