From 94409e4edfaf2e9a186ca068e46a4261eefc2b5a Mon Sep 17 00:00:00 2001 From: Federico Cappelli Date: Tue, 20 Aug 2024 14:27:18 +0100 Subject: [PATCH] Logging refactoring #1 Subscription and Content Blocking (#3091) Task/Issue URL: https://app.asana.com/0/1205842942115003/1206750146033742/f Tech Design URL: https://app.asana.com/0/1200194497630846/1206777133329590/f **Description**: Step 1 of the Logging refactoring Subscription Content Blocking User Scripts SecureVault History Remote messages General (removed and create local UserDefaultCache logger) --- .swiftlint.yml | 7 -- DuckDuckGo.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/swiftpm/Package.resolved | 6 +- .../xcschemes/sandbox-test-tool.xcscheme | 2 +- DuckDuckGo/Common/Logging/Logging.swift | 6 +- .../Configuration/ConfigurationManager.swift | 1 - .../ContentBlocker/ContentBlocking.swift | 3 +- .../Services/EncryptedHistoryStore.swift | 5 +- DuckDuckGo/Menus/MainMenu.swift | 82 +------------------ .../View/NavigationBarViewController.swift | 10 +-- .../MacTransparentProxyProvider.swift | 2 +- .../NetworkExtensionTargets/VPNLogger.swift | 3 +- .../ActiveRemoteMessageModel.swift | 5 +- .../RemoteMessagingClient.swift | 4 +- DuckDuckGo/Sync/SyncCredentialsAdapter.swift | 3 +- DuckDuckGo/Tab/Model/Tab.swift | 3 +- .../ContentBlockingTabExtension.swift | 5 +- .../SubscriptionErrorReporter.swift | 3 +- ...scriptionPagesUseSubscriptionFeature.swift | 11 +-- DuckDuckGoNotifications/Logging.swift | 2 +- .../DataBrokerProtection/Package.swift | 2 +- .../Sources/LoginItems/LoginItem.swift | 2 +- .../LoginItemLaunchInformation.swift | 1 - .../NetworkProtectionMac/Package.swift | 2 +- .../FlowManagers/TCPFlowManager.swift | 2 +- .../FlowManagers/UDPFlowManager.swift | 2 +- .../TransparentProxyAppMessageHandler.swift | 2 +- .../TransparentProxyController.swift | 2 +- .../TransparentProxyProvider.swift | 2 +- LocalPackages/SubscriptionUI/Package.swift | 2 +- .../Sources/UDSHelper/UDSClient.swift | 1 - .../Sources/UDSHelper/UDSReceiver.swift | 1 - .../Sources/UDSHelper/UDSServer.swift | 1 - 33 files changed, 47 insertions(+), 140 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index 459bfc874e..e96a0f5ab9 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -33,13 +33,6 @@ custom_rules: - keyword message: "Classes should be `final` by default, use explicit `internal` or `public` for non-final classes." severity: error - enforce_os_log_wrapper: - included: ".*\\.swift" - name: "Use `import Common` for os_log instead of `import os.log`" - regex: "^(import (?:os\\.log|os|OSLog))$" - capture_group: 0 - message: "os_log wrapper ensures log args are @autoclosures (computed when needed) and to be able to use String Interpolation." - severity: error # Rule Config cyclomatic_complexity: diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 47ae4cd844..4e271d21e7 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -13453,7 +13453,7 @@ repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit"; requirement = { kind = exactVersion; - version = 184.0.3; + version = 185.0.0; }; }; 9FF521422BAA8FF300B9819B /* XCRemoteSwiftPackageReference "lottie-spm" */ = { diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 246c3438a9..0a31c48e86 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/duckduckgo/BrowserServicesKit", "state" : { - "revision" : "f166fbddeb8c368f82b0c150a7fa0ff06031196d", - "version" : "184.0.3" + "revision" : "2efee14db4d30ac73916794de4d262b745a5f413", + "version" : "185.0.0" } }, { @@ -75,7 +75,7 @@ { "identity" : "lottie-spm", "kind" : "remoteSourceControl", - "location" : "https://github.com/airbnb/lottie-spm", + "location" : "https://github.com/airbnb/lottie-spm.git", "state" : { "revision" : "1d29eccc24cc8b75bff9f6804155112c0ffc9605", "version" : "4.4.3" diff --git a/DuckDuckGo.xcodeproj/xcshareddata/xcschemes/sandbox-test-tool.xcscheme b/DuckDuckGo.xcodeproj/xcshareddata/xcschemes/sandbox-test-tool.xcscheme index eb7e5e26bb..41730d7069 100644 --- a/DuckDuckGo.xcodeproj/xcshareddata/xcschemes/sandbox-test-tool.xcscheme +++ b/DuckDuckGo.xcodeproj/xcshareddata/xcschemes/sandbox-test-tool.xcscheme @@ -1,7 +1,7 @@ + version = "1.7"> { event, error, _, _ in diff --git a/DuckDuckGo/ContentBlocker/ContentBlocking.swift b/DuckDuckGo/ContentBlocker/ContentBlocking.swift index 555dfcd067..28825f7c5a 100644 --- a/DuckDuckGo/ContentBlocker/ContentBlocking.swift +++ b/DuckDuckGo/ContentBlocker/ContentBlocking.swift @@ -80,8 +80,7 @@ final class AppContentBlocking { contentBlockingManager = ContentBlockerRulesManager(rulesSource: contentBlockerRulesSource, exceptionsSource: exceptionsSource, cache: ContentBlockingRulesCache(), - errorReporting: Self.debugEvents, - log: .contentBlocking) + errorReporting: Self.debugEvents) userContentUpdating = UserContentUpdating(contentBlockerRulesManager: contentBlockingManager, privacyConfigurationManager: privacyConfigurationManager, trackerDataManager: trackerDataManager, diff --git a/DuckDuckGo/History/Services/EncryptedHistoryStore.swift b/DuckDuckGo/History/Services/EncryptedHistoryStore.swift index 2b5e9640d4..3c24c8cb55 100644 --- a/DuckDuckGo/History/Services/EncryptedHistoryStore.swift +++ b/DuckDuckGo/History/Services/EncryptedHistoryStore.swift @@ -22,6 +22,7 @@ import CoreData import Combine import History import PixelKit +import os.log final class EncryptedHistoryStore: HistoryStoring { @@ -90,7 +91,7 @@ final class EncryptedHistoryStore: HistoryStoring { for entry in entriesToDelete { context.delete(entry) } - os_log("%d items cleaned from history", log: .history, entriesToDelete.count) + Logger.history.debug("\(entriesToDelete.count) items cleaned from history") } catch { PixelKit.fire(DebugEvent(GeneralPixel.historyRemoveFailed, error: error)) self.context.reset() @@ -114,7 +115,7 @@ final class EncryptedHistoryStore: HistoryStoring { fetchRequest.returnsObjectsAsFaults = false do { let historyEntries = try context.fetch(fetchRequest) - os_log("%d entries loaded from history", log: .history, historyEntries.count) + Logger.history.debug("\(historyEntries.count) entries loaded from history") let history = BrowsingHistory(historyEntries: historyEntries) return .success(history) } catch { diff --git a/DuckDuckGo/Menus/MainMenu.swift b/DuckDuckGo/Menus/MainMenu.swift index 9bf35e587b..fefb5754e8 100644 --- a/DuckDuckGo/Menus/MainMenu.swift +++ b/DuckDuckGo/Menus/MainMenu.swift @@ -20,7 +20,7 @@ import BrowserServicesKit import Cocoa import Common import Combine -import OSLog // swiftlint:disable:this enforce_os_log_wrapper +import OSLog import SwiftUI import WebKit import Configuration @@ -408,7 +408,6 @@ final class MainMenu: NSMenu { updateHomeButtonMenuItem() updateBookmarksBarMenuItem() updateShortcutMenuItems() - updateLoggingMenuItems() updateInternalUserItem() updateRemoteConfigurationInfo() updateAutofillDebugScriptMenuItem() @@ -664,23 +663,6 @@ final class MainMenu: NSMenu { private func setupLoggingMenu() -> NSMenu { let menu = NSMenu(title: "") - menu.addItem(NSMenuItem(title: "Enable All", action: #selector(enableAllLogsMenuItemAction), target: self)) - menu.addItem(NSMenuItem(title: "Disable All", action: #selector(disableAllLogsMenuItemAction), target: self)) - menu.addItem(.separator()) - - for category in OSLog.AllCategories.allCases.sorted() { - let menuItem = NSMenuItem(title: category, action: #selector(loggingMenuItemAction), target: self) - menuItem.identifier = .init(category) - menu.addItem(menuItem) - } - - menu.addItem(autofillDebugScriptMenuItem - .targetting(self)) - - menu.addItem(.separator()) - let debugLoggingMenuItem = NSMenuItem(title: OSLog.isRunningInDebugEnvironment ? "Disable DEBUG level logging…" : "Enable DEBUG level logging…", action: #selector(debugLoggingMenuItemAction), target: self) - menu.addItem(debugLoggingMenuItem) - if #available(macOS 12.0, *) { let exportLogsMenuItem = NSMenuItem(title: "Save Logs…", action: #selector(exportLogs), target: self) menu.addItem(exportLogsMenuItem) @@ -694,17 +676,6 @@ final class MainMenu: NSMenu { internalUserItem.title = NSApp.delegateTyped.internalUserDecider.isInternalUser ? "Remove Internal User State" : "Set Internal User State" } - private func updateLoggingMenuItems() { - guard let loggingMenu else { return } - - let enabledCategories = OSLog.loggingCategories - for item in loggingMenu.items { - guard let category = item.identifier.map(\.rawValue) else { continue } - - item.state = enabledCategories.contains(category) ? .on : .off - } - } - private func updateAutofillDebugScriptMenuItem() { autofillDebugScriptMenuItem.state = AutofillPreferences().debugScriptEnabled ? .on : .off } @@ -721,63 +692,12 @@ final class MainMenu: NSMenu { customConfigurationUrlMenuItem.title = "Configuration URL: \(AppConfigurationURLProvider().url(for: .privacyConfiguration).absoluteString)" } - @objc private func loggingMenuItemAction(_ sender: NSMenuItem) { - guard let category = sender.identifier?.rawValue else { return } - - if case .on = sender.state { - OSLog.loggingCategories.remove(category) - } else { - OSLog.loggingCategories.insert(category) - } - } - - @objc private func enableAllLogsMenuItemAction(_ sender: NSMenuItem) { - OSLog.loggingCategories = Set(OSLog.AllCategories.allCases) - } - - @objc private func disableAllLogsMenuItemAction(_ sender: NSMenuItem) { - OSLog.loggingCategories = [] - } - @objc private func toggleAutofillScriptDebugSettingsAction(_ sender: NSMenuItem) { AutofillPreferences().debugScriptEnabled = !AutofillPreferences().debugScriptEnabled NotificationCenter.default.post(name: .autofillScriptDebugSettingsDidChange, object: nil) updateAutofillDebugScriptMenuItem() } - @objc private func debugLoggingMenuItemAction(_ sender: NSMenuItem) { -#if APPSTORE - if !OSLog.isRunningInDebugEnvironment { - let alert = NSAlert() - alert.messageText = "Restart with DEBUG logging Enabled not supported for AppStore build" - alert.informativeText = """ - Open terminal and run: - export \(ProcessInfo.Constants.osActivityMode)=\(ProcessInfo.Constants.debug) - "\(Bundle.main.executablePath!)" - """ - alert.runModal() - - return - } -#endif - - let alert = NSAlert() - alert.messageText = "Restart with DEBUG logging \(OSLog.isRunningInDebugEnvironment ? "Disabled" : "Enabled")?" - alert.addButton(withTitle: "Restart").tag = NSApplication.ModalResponse.OK.rawValue - alert.addButton(withTitle: "Cancel").tag = NSApplication.ModalResponse.cancel.rawValue - guard case .OK = alert.runModal() else { return } - - let config = NSWorkspace.OpenConfiguration() - config.createsNewApplicationInstance = true - config.environment = [ProcessInfo.Constants.osActivityMode: (OSLog.isRunningInDebugEnvironment ? "" : ProcessInfo.Constants.debug)] - - NSWorkspace.shared.openApplication(at: Bundle.main.bundleURL, configuration: config) - - DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { - NSApp.terminate(nil) - } - } - @available(macOS 12.0, *) @objc private func exportLogs(_ sender: NSMenuItem) { let displayName = Bundle.main.displayName!.replacingOccurrences(of: " ", with: "") diff --git a/DuckDuckGo/NavigationBar/View/NavigationBarViewController.swift b/DuckDuckGo/NavigationBar/View/NavigationBarViewController.swift index a8eee48ad4..ed07f0746a 100644 --- a/DuckDuckGo/NavigationBar/View/NavigationBarViewController.swift +++ b/DuckDuckGo/NavigationBar/View/NavigationBarViewController.swift @@ -21,7 +21,7 @@ import Combine import Common import BrowserServicesKit import PixelKit - +import os.log import NetworkProtection import NetworkProtectionIPC import NetworkProtectionUI @@ -866,23 +866,23 @@ final class NavigationBarViewController: NSViewController { let autofillPreferences = AutofillPreferences() if autofillPreferences.askToSaveUsernamesAndPasswords, let credentials = data.credentials { - os_log("Presenting Save Credentials popover", log: .passwordManager) + Logger.passwordManager.debug("Presenting Save Credentials popover") popovers.displaySaveCredentials(credentials, automaticallySaved: data.automaticallySavedCredentials, usingView: passwordManagementButton, withDelegate: self) } else if autofillPreferences.askToSavePaymentMethods, let card = data.creditCard { - os_log("Presenting Save Payment Method popover", log: .passwordManager) + Logger.passwordManager.debug("Presenting Save Payment Method popover") popovers.displaySavePaymentMethod(card, usingView: passwordManagementButton, withDelegate: self) } else if autofillPreferences.askToSaveAddresses, let identity = data.identity { - os_log("Presenting Save Identity popover", log: .passwordManager) + Logger.passwordManager.debug("Presenting Save Identity popover") popovers.displaySaveIdentity(identity, usingView: passwordManagementButton, withDelegate: self) } else { - os_log("Received save autofill data call, but there was no data to present", log: .passwordManager) + Logger.passwordManager.error("Received save autofill data call, but there was no data to present") } } diff --git a/DuckDuckGo/NetworkProtection/NetworkExtensionTargets/NetworkExtensionTargets/MacTransparentProxyProvider.swift b/DuckDuckGo/NetworkProtection/NetworkExtensionTargets/NetworkExtensionTargets/MacTransparentProxyProvider.swift index 1c4993210e..2319175e98 100644 --- a/DuckDuckGo/NetworkProtection/NetworkExtensionTargets/NetworkExtensionTargets/MacTransparentProxyProvider.swift +++ b/DuckDuckGo/NetworkProtection/NetworkExtensionTargets/NetworkExtensionTargets/MacTransparentProxyProvider.swift @@ -22,7 +22,7 @@ import Foundation import Networking import NetworkExtension import NetworkProtectionProxy -import os.log // swiftlint:disable:this enforce_os_log_wrapper +import os.log import PixelKit final class MacTransparentProxyProvider: TransparentProxyProvider { diff --git a/DuckDuckGo/NetworkProtection/NetworkExtensionTargets/NetworkExtensionTargets/VPNLogger.swift b/DuckDuckGo/NetworkProtection/NetworkExtensionTargets/NetworkExtensionTargets/VPNLogger.swift index f230701509..52f8000ea3 100644 --- a/DuckDuckGo/NetworkProtection/NetworkExtensionTargets/NetworkExtensionTargets/VPNLogger.swift +++ b/DuckDuckGo/NetworkProtection/NetworkExtensionTargets/NetworkExtensionTargets/VPNLogger.swift @@ -18,8 +18,7 @@ import Foundation import NetworkProtection -// swiftlint:disable:next enforce_os_log_wrapper -import OSLog +import os.log /// Logger for the VPN /// diff --git a/DuckDuckGo/RemoteMessaging/ActiveRemoteMessageModel.swift b/DuckDuckGo/RemoteMessaging/ActiveRemoteMessageModel.swift index 766298e177..854d989b07 100644 --- a/DuckDuckGo/RemoteMessaging/ActiveRemoteMessageModel.swift +++ b/DuckDuckGo/RemoteMessaging/ActiveRemoteMessageModel.swift @@ -22,6 +22,7 @@ import Common import Foundation import PixelKit import RemoteMessaging +import os.log /** * This is used to feed a remote message to the home page view. @@ -137,12 +138,12 @@ final class ActiveRemoteMessageModel: ObservableObject { guard let remoteMessage, let store = store() else { return } - os_log("Remote message shown: %s", log: .remoteMessaging, type: .info, remoteMessage.id) + Logger.remoteMessaging.info("Remote message shown: \(remoteMessage.id, privacy: .public)") if remoteMessage.isMetricsEnabled { PixelKit.fire(GeneralPixel.remoteMessageShown, withAdditionalParameters: ["message": remoteMessage.id]) } if !store.hasShownRemoteMessage(withID: remoteMessage.id) { - os_log("Remote message shown for first time: %s", log: .remoteMessaging, type: .info, remoteMessage.id) + Logger.remoteMessaging.info("Remote message shown for first time: \(remoteMessage.id, privacy: .public)") if remoteMessage.isMetricsEnabled { PixelKit.fire(GeneralPixel.remoteMessageShownUnique, withAdditionalParameters: ["message": remoteMessage.id]) } diff --git a/DuckDuckGo/RemoteMessaging/RemoteMessagingClient.swift b/DuckDuckGo/RemoteMessaging/RemoteMessagingClient.swift index 6e4b10376e..4151ed5164 100644 --- a/DuckDuckGo/RemoteMessaging/RemoteMessagingClient.swift +++ b/DuckDuckGo/RemoteMessaging/RemoteMessagingClient.swift @@ -36,8 +36,7 @@ struct DefaultRemoteMessagingStoreProvider: RemoteMessagingStoreProviding { database: database, notificationCenter: .default, errorEvents: RemoteMessagingStoreErrorHandling(), - remoteMessagingAvailabilityProvider: availabilityProvider, - log: .remoteMessaging + remoteMessagingAvailabilityProvider: availabilityProvider ) } } @@ -98,7 +97,6 @@ final class RemoteMessagingClient: RemoteMessagingProcessing { configurationFetcher: ConfigurationFetcher( store: configurationStore, urlSession: .session(), - log: .remoteMessaging, eventMapping: ConfigurationManager.configurationDebugEvents ), configurationStore: ConfigurationStore.shared diff --git a/DuckDuckGo/Sync/SyncCredentialsAdapter.swift b/DuckDuckGo/Sync/SyncCredentialsAdapter.swift index 4ffaa44081..aa857a40cb 100644 --- a/DuckDuckGo/Sync/SyncCredentialsAdapter.swift +++ b/DuckDuckGo/Sync/SyncCredentialsAdapter.swift @@ -38,8 +38,7 @@ final class SyncCredentialsAdapter { databaseCleaner = CredentialsDatabaseCleaner( secureVaultFactory: secureVaultFactory, secureVaultErrorReporter: SecureVaultReporter.shared, - errorEvents: CredentialsCleanupErrorHandling(), - log: .passwordManager + errorEvents: CredentialsCleanupErrorHandling() ) } diff --git a/DuckDuckGo/Tab/Model/Tab.swift b/DuckDuckGo/Tab/Model/Tab.swift index 3739a2dc9e..c556a18b0f 100644 --- a/DuckDuckGo/Tab/Model/Tab.swift +++ b/DuckDuckGo/Tab/Model/Tab.swift @@ -25,6 +25,7 @@ import UserScript import WebKit import History import PixelKit +import os.log protocol TabDelegate: ContentOverlayUserScriptDelegate { func tabWillStartNavigation(_ tab: Tab, isUserInitiated: Bool) @@ -1012,7 +1013,7 @@ extension Tab: UserContentControllerDelegate { @MainActor func userContentController(_ userContentController: UserContentController, didInstallContentRuleLists contentRuleLists: [String: WKContentRuleList], userScripts: UserScriptsProvider, updateEvent: ContentBlockerRulesManager.UpdateEvent) { - os_log("didInstallContentRuleLists", log: .contentBlocking, type: .info) + Logger.contentBlocking.info("didInstallContentRuleLists") guard let userScripts = userScripts as? UserScripts else { fatalError("Unexpected UserScripts") } userScripts.debugScript.instrumentation = instrumentation diff --git a/DuckDuckGo/Tab/TabExtensions/ContentBlockingTabExtension.swift b/DuckDuckGo/Tab/TabExtensions/ContentBlockingTabExtension.swift index 7ab4f5ddc6..10b1a31840 100644 --- a/DuckDuckGo/Tab/TabExtensions/ContentBlockingTabExtension.swift +++ b/DuckDuckGo/Tab/TabExtensions/ContentBlockingTabExtension.swift @@ -22,6 +22,7 @@ import Common import ContentBlocking import Foundation import Navigation +import os.log struct DetectedTracker { enum TrackerType { @@ -109,7 +110,7 @@ extension ContentBlockingTabExtension: NavigationResponder { // Ensure Content Blocking Assets (WKContentRuleList&UserScripts) are installed if userContentController?.contentBlockingAssetsInstalled == false && privacyConfigurationManager.privacyConfig.isEnabled(featureKey: .contentBlocking) { - os_log("%d: tabWillWaitForRulesCompilation", log: .contentBlocking, identifier) + Logger.contentBlocking.log("\(self.identifier) tabWillWaitForRulesCompilation") cbaTimeReporter?.tabWillWaitForRulesCompilation(identifier) disableLongDecisionMakingChecks() @@ -118,7 +119,7 @@ extension ContentBlockingTabExtension: NavigationResponder { } await userContentController?.awaitContentBlockingAssetsInstalled() - os_log("%d: Rules Compilation done", log: .contentBlocking, identifier) + Logger.contentBlocking.log("\(self.identifier) Rules Compilation done") cbaTimeReporter?.reportWaitTimeForTabFinishedWaitingForRules(identifier) } else { cbaTimeReporter?.reportNavigationDidNotWaitForRules() diff --git a/DuckDuckGo/Tab/UserScripts/Subscription/SubscriptionErrorReporter.swift b/DuckDuckGo/Tab/UserScripts/Subscription/SubscriptionErrorReporter.swift index 0058cebd4f..c1d62a8033 100644 --- a/DuckDuckGo/Tab/UserScripts/Subscription/SubscriptionErrorReporter.swift +++ b/DuckDuckGo/Tab/UserScripts/Subscription/SubscriptionErrorReporter.swift @@ -19,6 +19,7 @@ import Foundation import Common import PixelKit +import os.log enum SubscriptionError: Error { case purchaseFailed, @@ -45,7 +46,7 @@ struct DefaultSubscriptionErrorReporter: SubscriptionErrorReporter { func report(subscriptionActivationError: SubscriptionError) { - os_log(.error, log: .subscription, "Subscription purchase error: %{public}s", subscriptionActivationError.localizedDescription) + Logger.subscription.error("Subscription purchase error: \(subscriptionActivationError.localizedDescription, privacy: .public)") var isStoreError = false var isBackendError = false diff --git a/DuckDuckGo/Tab/UserScripts/Subscription/SubscriptionPagesUseSubscriptionFeature.swift b/DuckDuckGo/Tab/UserScripts/Subscription/SubscriptionPagesUseSubscriptionFeature.swift index 2251e93e27..535083717b 100644 --- a/DuckDuckGo/Tab/UserScripts/Subscription/SubscriptionPagesUseSubscriptionFeature.swift +++ b/DuckDuckGo/Tab/UserScripts/Subscription/SubscriptionPagesUseSubscriptionFeature.swift @@ -24,6 +24,7 @@ import WebKit import UserScript import Subscription import PixelKit +import os.log /// Use Subscription sub-feature final class SubscriptionPagesUseSubscriptionFeature: Subfeature { @@ -186,14 +187,14 @@ final class SubscriptionPagesUseSubscriptionFeature: Subfeature { return nil } - os_log(.info, log: .subscription, "[Purchase] Starting purchase for: %{public}s", subscriptionSelection.id) + Logger.subscription.info("[Purchase] Starting purchase for: \(subscriptionSelection.id, privacy: .public)") await uiHandler.presentProgressViewController(withTitle: UserText.purchasingSubscriptionTitle) // Check for active subscriptions if await subscriptionManager.storePurchaseManager().hasActiveSubscription() { PixelKit.fire(PrivacyProPixel.privacyProRestoreAfterPurchaseAttempt) - os_log(.info, log: .subscription, "[Purchase] Found active subscription during purchase") + Logger.subscription.info("[Purchase] Found active subscription during purchase") subscriptionErrorReporter.report(subscriptionActivationError: .hasActiveSubscription) await showSubscriptionFoundAlert(originalMessage: message) await pushPurchaseUpdate(originalMessage: message, purchaseUpdate: PurchaseUpdate(type: "canceled")) @@ -212,7 +213,7 @@ final class SubscriptionPagesUseSubscriptionFeature: Subfeature { appStoreRestoreFlow: appStoreRestoreFlow, authEndpointService: subscriptionManager.authEndpointService) - os_log(.info, log: .subscription, "[Purchase] Purchasing") + Logger.subscription.info("[Purchase] Purchasing") switch await appStorePurchaseFlow.purchaseSubscription(with: subscriptionSelection.id, emailAccessToken: emailAccessToken) { case .success(let transactionJWS): purchaseTransactionJWS = transactionJWS @@ -247,11 +248,11 @@ final class SubscriptionPagesUseSubscriptionFeature: Subfeature { await uiHandler.updateProgressViewController(title: UserText.completingPurchaseTitle) - os_log(.info, log: .subscription, "[Purchase] Completing purchase") + Logger.subscription.info("[Purchase] Completing purchase") let completePurchaseResult = await appStorePurchaseFlow.completeSubscriptionPurchase(with: purchaseTransactionJWS) switch completePurchaseResult { case .success(let purchaseUpdate): - os_log(.info, log: .subscription, "[Purchase] Purchase complete") + Logger.subscription.info("[Purchase] Purchase complete") PixelKit.fire(PrivacyProPixel.privacyProPurchaseSuccess, frequency: .dailyAndCount) PixelKit.fire(PrivacyProPixel.privacyProSubscriptionActivated, frequency: .unique) subscriptionSuccessPixelHandler.fireSuccessfulSubscriptionAttributionPixel() diff --git a/DuckDuckGoNotifications/Logging.swift b/DuckDuckGoNotifications/Logging.swift index 1d8516705b..30c5d6fbe5 100644 --- a/DuckDuckGoNotifications/Logging.swift +++ b/DuckDuckGoNotifications/Logging.swift @@ -17,7 +17,7 @@ // import Foundation -import os // swiftlint:disable:this enforce_os_log_wrapper +import os.log extension OSLog { diff --git a/LocalPackages/DataBrokerProtection/Package.swift b/LocalPackages/DataBrokerProtection/Package.swift index 3f55cd980c..9189f243a3 100644 --- a/LocalPackages/DataBrokerProtection/Package.swift +++ b/LocalPackages/DataBrokerProtection/Package.swift @@ -29,7 +29,7 @@ let package = Package( targets: ["DataBrokerProtection"]) ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "184.0.3"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "185.0.0"), .package(path: "../SwiftUIExtensions"), .package(path: "../XPCHelper"), ], diff --git a/LocalPackages/LoginItems/Sources/LoginItems/LoginItem.swift b/LocalPackages/LoginItems/Sources/LoginItems/LoginItem.swift index 48a16a8689..eecea5a8ba 100644 --- a/LocalPackages/LoginItems/Sources/LoginItems/LoginItem.swift +++ b/LocalPackages/LoginItems/Sources/LoginItems/LoginItem.swift @@ -17,7 +17,7 @@ // import AppKit -import os.log // swiftlint:disable:this enforce_os_log_wrapper +import os.log import Foundation import ServiceManagement diff --git a/LocalPackages/LoginItems/Sources/LoginItems/LoginItemLaunchInformation.swift b/LocalPackages/LoginItems/Sources/LoginItems/LoginItemLaunchInformation.swift index f6e559f430..802388b5c4 100644 --- a/LocalPackages/LoginItems/Sources/LoginItems/LoginItemLaunchInformation.swift +++ b/LocalPackages/LoginItems/Sources/LoginItems/LoginItemLaunchInformation.swift @@ -18,7 +18,6 @@ import Foundation import AppKit -// swiftlint:disable:next enforce_os_log_wrapper import os.log public struct LoginItemLaunchInformation: Equatable, Hashable { diff --git a/LocalPackages/NetworkProtectionMac/Package.swift b/LocalPackages/NetworkProtectionMac/Package.swift index 635a577bbd..01cfa2e187 100644 --- a/LocalPackages/NetworkProtectionMac/Package.swift +++ b/LocalPackages/NetworkProtectionMac/Package.swift @@ -32,7 +32,7 @@ let package = Package( .library(name: "VPNAppLauncher", targets: ["VPNAppLauncher"]), ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "184.0.3"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "185.0.0"), .package(url: "https://github.com/airbnb/lottie-spm", exact: "4.4.3"), .package(path: "../AppLauncher"), .package(path: "../UDSHelper"), diff --git a/LocalPackages/NetworkProtectionMac/Sources/NetworkProtectionProxy/FlowManagers/TCPFlowManager.swift b/LocalPackages/NetworkProtectionMac/Sources/NetworkProtectionProxy/FlowManagers/TCPFlowManager.swift index edf987d201..dcfb727d6b 100644 --- a/LocalPackages/NetworkProtectionMac/Sources/NetworkProtectionProxy/FlowManagers/TCPFlowManager.swift +++ b/LocalPackages/NetworkProtectionMac/Sources/NetworkProtectionProxy/FlowManagers/TCPFlowManager.swift @@ -18,7 +18,7 @@ import Foundation import NetworkExtension -import OSLog // swiftlint:disable:this enforce_os_log_wrapper +import os.log /// A private global actor to handle UDP flows management /// diff --git a/LocalPackages/NetworkProtectionMac/Sources/NetworkProtectionProxy/FlowManagers/UDPFlowManager.swift b/LocalPackages/NetworkProtectionMac/Sources/NetworkProtectionProxy/FlowManagers/UDPFlowManager.swift index 000f37d20e..58fbc4dd1e 100644 --- a/LocalPackages/NetworkProtectionMac/Sources/NetworkProtectionProxy/FlowManagers/UDPFlowManager.swift +++ b/LocalPackages/NetworkProtectionMac/Sources/NetworkProtectionProxy/FlowManagers/UDPFlowManager.swift @@ -18,7 +18,7 @@ import Foundation import NetworkExtension -import OSLog // swiftlint:disable:this enforce_os_log_wrapper +import os.log /// A private global actor to handle UDP flows management /// diff --git a/LocalPackages/NetworkProtectionMac/Sources/NetworkProtectionProxy/IPC/TransparentProxyAppMessageHandler.swift b/LocalPackages/NetworkProtectionMac/Sources/NetworkProtectionProxy/IPC/TransparentProxyAppMessageHandler.swift index 988ffd1f77..48ae78e457 100644 --- a/LocalPackages/NetworkProtectionMac/Sources/NetworkProtectionProxy/IPC/TransparentProxyAppMessageHandler.swift +++ b/LocalPackages/NetworkProtectionMac/Sources/NetworkProtectionProxy/IPC/TransparentProxyAppMessageHandler.swift @@ -17,7 +17,7 @@ // import Foundation -import OSLog // swiftlint:disable:this enforce_os_log_wrapper +import os.log import NetworkExtension /// Handles app messages diff --git a/LocalPackages/NetworkProtectionMac/Sources/NetworkProtectionProxy/TransparentProxyController.swift b/LocalPackages/NetworkProtectionMac/Sources/NetworkProtectionProxy/TransparentProxyController.swift index fdc7fb3177..c936936427 100644 --- a/LocalPackages/NetworkProtectionMac/Sources/NetworkProtectionProxy/TransparentProxyController.swift +++ b/LocalPackages/NetworkProtectionMac/Sources/NetworkProtectionProxy/TransparentProxyController.swift @@ -20,7 +20,7 @@ import Combine import Foundation import NetworkExtension import NetworkProtection -import OSLog // swiftlint:disable:this enforce_os_log_wrapper +import os.log import PixelKit import SystemExtensions diff --git a/LocalPackages/NetworkProtectionMac/Sources/NetworkProtectionProxy/TransparentProxyProvider.swift b/LocalPackages/NetworkProtectionMac/Sources/NetworkProtectionProxy/TransparentProxyProvider.swift index c71dbc9ee1..ae57c6416f 100644 --- a/LocalPackages/NetworkProtectionMac/Sources/NetworkProtectionProxy/TransparentProxyProvider.swift +++ b/LocalPackages/NetworkProtectionMac/Sources/NetworkProtectionProxy/TransparentProxyProvider.swift @@ -20,7 +20,7 @@ import Combine import Foundation import NetworkExtension import NetworkProtection -import os.log // swiftlint:disable:this enforce_os_log_wrapper +import os.log import SystemConfiguration open class TransparentProxyProvider: NETransparentProxyProvider { diff --git a/LocalPackages/SubscriptionUI/Package.swift b/LocalPackages/SubscriptionUI/Package.swift index fd80f36341..9c01fa5733 100644 --- a/LocalPackages/SubscriptionUI/Package.swift +++ b/LocalPackages/SubscriptionUI/Package.swift @@ -12,7 +12,7 @@ let package = Package( targets: ["SubscriptionUI"]), ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "184.0.3"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "185.0.0"), .package(path: "../SwiftUIExtensions") ], targets: [ diff --git a/LocalPackages/UDSHelper/Sources/UDSHelper/UDSClient.swift b/LocalPackages/UDSHelper/Sources/UDSHelper/UDSClient.swift index 023f350761..1c3f153176 100644 --- a/LocalPackages/UDSHelper/Sources/UDSHelper/UDSClient.swift +++ b/LocalPackages/UDSHelper/Sources/UDSHelper/UDSClient.swift @@ -18,7 +18,6 @@ import Foundation import Network -// swiftlint:disable:next enforce_os_log_wrapper import os.log public actor UDSClient { diff --git a/LocalPackages/UDSHelper/Sources/UDSHelper/UDSReceiver.swift b/LocalPackages/UDSHelper/Sources/UDSHelper/UDSReceiver.swift index 90e55c25dd..6ad9e5bef6 100644 --- a/LocalPackages/UDSHelper/Sources/UDSHelper/UDSReceiver.swift +++ b/LocalPackages/UDSHelper/Sources/UDSHelper/UDSReceiver.swift @@ -18,7 +18,6 @@ import Foundation import Network -// swiftlint:disable:next enforce_os_log_wrapper import os.log typealias UDSMessageLength = UInt16 diff --git a/LocalPackages/UDSHelper/Sources/UDSHelper/UDSServer.swift b/LocalPackages/UDSHelper/Sources/UDSHelper/UDSServer.swift index 41812e5819..ed72e65fb7 100644 --- a/LocalPackages/UDSHelper/Sources/UDSHelper/UDSServer.swift +++ b/LocalPackages/UDSHelper/Sources/UDSHelper/UDSServer.swift @@ -18,7 +18,6 @@ import Foundation import Network -// swiftlint:disable:next enforce_os_log_wrapper import os.log /// Convenience Hashable support for `NWConnection`, so we can use `Set`