1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-10 05:13:29 +00:00

[BEEEP] Use tracing in macOS provider (#16729)

* [BEEEP] Use tracing in macOS provider

* set log level filter to INFO

* only call global subscribe once
This commit is contained in:
neuronull
2025-10-20 07:20:15 -07:00
committed by GitHub
parent 7c972906aa
commit 44ce303181
3 changed files with 38 additions and 6 deletions

View File

@@ -1817,13 +1817,14 @@ version = "0.0.0"
dependencies = [
"desktop_core",
"futures",
"log",
"oslog",
"serde",
"serde_json",
"tokio",
"tokio-util",
"tracing",
"tracing-oslog",
"tracing-subscriber",
"uniffi",
]
@@ -3413,6 +3414,18 @@ dependencies = [
"tracing-core",
]
[[package]]
name = "tracing-oslog"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d76902d2a8d5f9f55a81155c08971734071968c90f2d9bfe645fe700579b2950"
dependencies = [
"cc",
"cfg-if",
"tracing-core",
"tracing-subscriber",
]
[[package]]
name = "tracing-subscriber"
version = "0.3.20"

View File

@@ -16,12 +16,13 @@ bench = false
[dependencies]
desktop_core = { path = "../core" }
futures = { workspace = true }
log = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
tokio = { workspace = true, features = ["sync"] }
tokio-util = { workspace = true }
tracing = { workspace = true }
tracing-oslog = "0.3.0"
tracing-subscriber = { workspace = true }
uniffi = { workspace = true, features = ["cli"] }
[target.'cfg(target_os = "macos")'.dependencies]

View File

@@ -2,13 +2,18 @@
use std::{
collections::HashMap,
sync::{atomic::AtomicU32, Arc, Mutex},
sync::{atomic::AtomicU32, Arc, Mutex, Once},
time::Instant,
};
use futures::FutureExt;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use tracing::{error, info};
use tracing_subscriber::{
filter::{EnvFilter, LevelFilter},
layer::SubscriberExt,
util::SubscriberInitExt,
};
uniffi::setup_scaffolding!();
@@ -21,6 +26,8 @@ use assertion::{
};
use registration::{PasskeyRegistrationRequest, PreparePasskeyRegistrationCallback};
static INIT: Once = Once::new();
#[derive(uniffi::Enum, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum UserVerification {
@@ -65,9 +72,20 @@ impl MacOSProviderClient {
#[allow(clippy::unwrap_used)]
#[uniffi::constructor]
pub fn connect() -> Self {
let _ = oslog::OsLogger::new("com.bitwarden.desktop.autofill-extension")
.level_filter(log::LevelFilter::Trace)
.init();
INIT.call_once(|| {
let filter = EnvFilter::builder()
// Everything logs at `INFO`
.with_default_directive(LevelFilter::INFO.into())
.from_env_lossy();
tracing_subscriber::registry()
.with(filter)
.with(tracing_oslog::OsLogger::new(
"com.bitwarden.desktop.autofill-extension",
"default",
))
.init();
});
let (from_server_send, mut from_server_recv) = tokio::sync::mpsc::channel(32);
let (to_server_send, to_server_recv) = tokio::sync::mpsc::channel(32);