diff --git a/apps/desktop/desktop_native/autofill_provider/src/lib.rs b/apps/desktop/desktop_native/autofill_provider/src/lib.rs index 6d7e2b01a17..e210d1730ac 100644 --- a/apps/desktop/desktop_native/autofill_provider/src/lib.rs +++ b/apps/desktop/desktop_native/autofill_provider/src/lib.rs @@ -198,22 +198,6 @@ impl AutofillProviderClient { /// /// See documentation at the top-level of [this struct][AutofillProviderClient] for usage information. pub fn connect() -> Self { - #[cfg(target_os = "macos")] - 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(); - }); - tracing::trace!("Autofill provider attempting to connect to Electron IPC..."); let (from_server_send, mut from_server_recv) = tokio::sync::mpsc::channel(32); @@ -336,6 +320,25 @@ impl AutofillProviderClient { } } +#[cfg(target_os = "macos")] +#[uniffi::export] +pub fn initialize_logging() { + 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(); + }); +} + #[derive(Serialize, Deserialize)] #[serde(tag = "command", rename_all = "camelCase")] enum CommandMessage { diff --git a/apps/desktop/macos/autofill-extension/CredentialProviderViewController.swift b/apps/desktop/macos/autofill-extension/CredentialProviderViewController.swift index c04a11051b4..437392aab0c 100644 --- a/apps/desktop/macos/autofill-extension/CredentialProviderViewController.swift +++ b/apps/desktop/macos/autofill-extension/CredentialProviderViewController.swift @@ -30,6 +30,7 @@ class CredentialProviderViewController: ASCredentialProviderViewController { return client } + initializeLogging() let logger = Logger(subsystem: "com.bitwarden.desktop.autofill-extension", category: "credential-provider") // Check if the Electron app is running