mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 05:43:41 +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:
15
apps/desktop/desktop_native/Cargo.lock
generated
15
apps/desktop/desktop_native/Cargo.lock
generated
@@ -1817,13 +1817,14 @@ version = "0.0.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"desktop_core",
|
"desktop_core",
|
||||||
"futures",
|
"futures",
|
||||||
"log",
|
|
||||||
"oslog",
|
"oslog",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
"tracing-oslog",
|
||||||
|
"tracing-subscriber",
|
||||||
"uniffi",
|
"uniffi",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -3413,6 +3414,18 @@ dependencies = [
|
|||||||
"tracing-core",
|
"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]]
|
[[package]]
|
||||||
name = "tracing-subscriber"
|
name = "tracing-subscriber"
|
||||||
version = "0.3.20"
|
version = "0.3.20"
|
||||||
|
|||||||
@@ -16,12 +16,13 @@ bench = false
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
desktop_core = { path = "../core" }
|
desktop_core = { path = "../core" }
|
||||||
futures = { workspace = true }
|
futures = { workspace = true }
|
||||||
log = { workspace = true }
|
|
||||||
serde = { workspace = true, features = ["derive"] }
|
serde = { workspace = true, features = ["derive"] }
|
||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
tokio = { workspace = true, features = ["sync"] }
|
tokio = { workspace = true, features = ["sync"] }
|
||||||
tokio-util = { workspace = true }
|
tokio-util = { workspace = true }
|
||||||
tracing = { workspace = true }
|
tracing = { workspace = true }
|
||||||
|
tracing-oslog = "0.3.0"
|
||||||
|
tracing-subscriber = { workspace = true }
|
||||||
uniffi = { workspace = true, features = ["cli"] }
|
uniffi = { workspace = true, features = ["cli"] }
|
||||||
|
|
||||||
[target.'cfg(target_os = "macos")'.dependencies]
|
[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
|
|||||||
@@ -2,13 +2,18 @@
|
|||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
sync::{atomic::AtomicU32, Arc, Mutex},
|
sync::{atomic::AtomicU32, Arc, Mutex, Once},
|
||||||
time::Instant,
|
time::Instant,
|
||||||
};
|
};
|
||||||
|
|
||||||
use futures::FutureExt;
|
use futures::FutureExt;
|
||||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||||
use tracing::{error, info};
|
use tracing::{error, info};
|
||||||
|
use tracing_subscriber::{
|
||||||
|
filter::{EnvFilter, LevelFilter},
|
||||||
|
layer::SubscriberExt,
|
||||||
|
util::SubscriberInitExt,
|
||||||
|
};
|
||||||
|
|
||||||
uniffi::setup_scaffolding!();
|
uniffi::setup_scaffolding!();
|
||||||
|
|
||||||
@@ -21,6 +26,8 @@ use assertion::{
|
|||||||
};
|
};
|
||||||
use registration::{PasskeyRegistrationRequest, PreparePasskeyRegistrationCallback};
|
use registration::{PasskeyRegistrationRequest, PreparePasskeyRegistrationCallback};
|
||||||
|
|
||||||
|
static INIT: Once = Once::new();
|
||||||
|
|
||||||
#[derive(uniffi::Enum, Debug, Serialize, Deserialize)]
|
#[derive(uniffi::Enum, Debug, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub enum UserVerification {
|
pub enum UserVerification {
|
||||||
@@ -65,9 +72,20 @@ impl MacOSProviderClient {
|
|||||||
#[allow(clippy::unwrap_used)]
|
#[allow(clippy::unwrap_used)]
|
||||||
#[uniffi::constructor]
|
#[uniffi::constructor]
|
||||||
pub fn connect() -> Self {
|
pub fn connect() -> Self {
|
||||||
let _ = oslog::OsLogger::new("com.bitwarden.desktop.autofill-extension")
|
INIT.call_once(|| {
|
||||||
.level_filter(log::LevelFilter::Trace)
|
let filter = EnvFilter::builder()
|
||||||
.init();
|
// 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 (from_server_send, mut from_server_recv) = tokio::sync::mpsc::channel(32);
|
||||||
let (to_server_send, to_server_recv) = tokio::sync::mpsc::channel(32);
|
let (to_server_send, to_server_recv) = tokio::sync::mpsc::channel(32);
|
||||||
|
|||||||
Reference in New Issue
Block a user