Skip to content

Commit

Permalink
All DBP logs reverted to the default level instead of debug. (#3704)
Browse files Browse the repository at this point in the history
Task/Issue URL:
https://app.asana.com/0/1205842942115003/1208612332501635/f

**Description**:
All `.debug` logs replaced with default `.log` in:
- The DBP folder in the main app
- The DataBrokerProtection local package
- The DBPBackgroundAgent
  • Loading branch information
federicocappelli authored Jan 9, 2025
1 parent 724a3bd commit 7fcd3e5
Show file tree
Hide file tree
Showing 22 changed files with 87 additions and 87 deletions.
6 changes: 3 additions & 3 deletions DuckDuckGo/DBP/DataBrokerProtectionDebugMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,21 +175,21 @@ final class DataBrokerProtectionDebugMenu: NSMenu {
}

@objc private func startScheduledOperations(_ sender: NSMenuItem) {
Logger.dataBrokerProtection.debug("Running queued operations...")
Logger.dataBrokerProtection.log("Running queued operations...")
let showWebView = sender.representedObject as? Bool ?? false

DataBrokerProtectionManager.shared.loginItemInterface.startScheduledOperations(showWebView: showWebView)
}

@objc private func runScanOperations(_ sender: NSMenuItem) {
Logger.dataBrokerProtection.debug("Running scan operations...")
Logger.dataBrokerProtection.log("Running scan operations...")
let showWebView = sender.representedObject as? Bool ?? false

DataBrokerProtectionManager.shared.loginItemInterface.startImmediateOperations(showWebView: showWebView)
}

@objc private func runOptoutOperations(_ sender: NSMenuItem) {
Logger.dataBrokerProtection.debug("Running Optout operations...")
Logger.dataBrokerProtection.log("Running Optout operations...")
let showWebView = sender.representedObject as? Bool ?? false

DataBrokerProtectionManager.shared.loginItemInterface.runAllOptOuts(showWebView: showWebView)
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/DBP/DataBrokerProtectionFeatureGatekeeper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct DefaultDataBrokerProtectionFeatureGatekeeper: DataBrokerProtectionFeature
func disableAndDeleteForAllUsers() {
featureDisabler.disableAndDelete()

Logger.dataBrokerProtection.debug("Disabling and removing DBP for all users")
Logger.dataBrokerProtection.log("Disabling and removing DBP for all users")
}

/// Checks DBP prerequisites
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class DuckDuckGoDBPBackgroundAgentApplication: NSApplication {
private let subscriptionManager: SubscriptionManager

override init() {
Logger.dbpBackgroundAgent.info("🟢 Starting: \(NSRunningApplication.current.processIdentifier, privacy: .public)")
Logger.dbpBackgroundAgent.log("🟢 Starting: \(NSRunningApplication.current.processIdentifier, privacy: .public)")

let dryRun: Bool
#if DEBUG
Expand Down Expand Up @@ -97,7 +97,7 @@ final class DuckDuckGoDBPBackgroundAgentAppDelegate: NSObject, NSApplicationDele

@MainActor
func applicationDidFinishLaunching(_ aNotification: Notification) {
Logger.dbpBackgroundAgent.info("DuckDuckGoAgent started")
Logger.dbpBackgroundAgent.log("DuckDuckGoAgent started")

let redeemUseCase = RedeemUseCase(authenticationService: AuthenticationService(),
authenticationRepository: KeychainAuthenticationData())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,20 @@ struct DataBrokerProtectionFeature: Subfeature {
case .actionError: return onActionError
}
} else {
Logger.action.debug("Cant parse method: \(methodName, privacy: .public)")
Logger.action.log("Cant parse method: \(methodName, privacy: .public)")
return nil
}
}

func onActionCompleted(params: Any, original: WKScriptMessage) async throws -> Encodable? {
Logger.action.debug("Action completed")
Logger.action.log("Action completed")

await parseActionCompleted(params: params)
return nil
}

func parseActionCompleted(params: Any) async {
Logger.action.debug("Parse action completed")
Logger.action.log("Parse action completed")

guard let data = try? JSONSerialization.data(withJSONObject: params),
let result = try? JSONDecoder().decode(CCFResult.self, from: data) else {
Expand All @@ -91,7 +91,7 @@ struct DataBrokerProtectionFeature: Subfeature {
}

func parseSuccess(success: CCFSuccessResponse) async {
Logger.action.debug("Parse success: \(String(describing: success.actionType.rawValue), privacy: .public)")
Logger.action.log("Parse success: \(String(describing: success.actionType.rawValue), privacy: .public)")

switch success.response {
case .navigate(let navigate):
Expand All @@ -114,7 +114,7 @@ struct DataBrokerProtectionFeature: Subfeature {

func onActionError(params: Any, original: WKScriptMessage) async throws -> Encodable? {
let error = DataBrokerProtectionError.parse(params: params)
Logger.action.debug("Action Error: \(String(describing: error.localizedDescription), privacy: .public)")
Logger.action.log("Action Error: \(String(describing: error.localizedDescription), privacy: .public)")

await delegate?.onError(error: error)
return nil
Expand All @@ -129,7 +129,7 @@ struct DataBrokerProtectionFeature: Subfeature {
assertionFailure("Cannot continue without broker instance")
return
}
Logger.action.debug("Pushing into WebView: \(method.rawValue) params \(String(describing: params))")
Logger.action.log("Pushing into WebView: \(method.rawValue) params \(String(describing: params))")

broker.push(method: method.rawValue, params: params, for: self, into: webView)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ final class DataBrokerUserContentController: WKUserContentController {

@MainActor
public func cleanUpBeforeClosing() {
Logger.dataBrokerProtection.debug("Cleaning up DBP user scripts")
Logger.dataBrokerProtection.log("Cleaning up DBP user scripts")

self.removeAllUserScripts()
self.removeAllScriptMessageHandlers()
Expand All @@ -61,7 +61,7 @@ final class DataBrokerUserContentController: WKUserContentController {
}

deinit {
Logger.dataBrokerProtection.debug("DataBrokerUserContentController Deinit")
Logger.dataBrokerProtection.log("DataBrokerUserContentController Deinit")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ final class DataBrokerProtectionWebViewHandler: NSObject, WebViewHandler {

func load(url: URL) async throws {
webView?.load(url)
Logger.action.debug("Loading URL: \(String(describing: url.absoluteString))")
Logger.action.log("Loading URL: \(String(describing: url.absoluteString))")
try await waitForWebViewLoad()
}

Expand All @@ -98,11 +98,11 @@ final class DataBrokerProtectionWebViewHandler: NSObject, WebViewHandler {
}

func finish() {
Logger.action.debug("WebViewHandler finished")
Logger.action.log("WebViewHandler finished")
webView?.stopLoading()
userContentController?.cleanUpBeforeClosing()
WKWebsiteDataStore.default().removeData(ofTypes: [WKWebsiteDataTypeDiskCache, WKWebsiteDataTypeMemoryCache], modifiedSince: Date(timeIntervalSince1970: 0)) {
Logger.action.debug("WKWebView data store deleted correctly")
Logger.action.log("WKWebView data store deleted correctly")
}

stopTimer()
Expand All @@ -114,7 +114,7 @@ final class DataBrokerProtectionWebViewHandler: NSObject, WebViewHandler {
}

deinit {
Logger.action.debug("WebViewHandler Deinit")
Logger.action.log("WebViewHandler Deinit")
}

func waitForWebViewLoad() async throws {
Expand All @@ -124,7 +124,7 @@ final class DataBrokerProtectionWebViewHandler: NSObject, WebViewHandler {
}

func execute(action: Action, data: CCFRequestData) {
Logger.action.debug("Executing action: \(String(describing: action.actionType.rawValue), privacy: .public)")
Logger.action.log("Executing action: \(String(describing: action.actionType.rawValue), privacy: .public)")

userContentController?.dataBrokerUserScripts?.dataBrokerFeature.pushAction(
method: .onActionReceived,
Expand Down Expand Up @@ -225,7 +225,7 @@ extension DataBrokerProtectionWebViewHandler: WKNavigationDelegate {
}

func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
Logger.action.debug("WebViewHandler didFinish")
Logger.action.log("WebViewHandler didFinish")

self.activeContinuation?.resume()
self.activeContinuation = nil
Expand All @@ -250,7 +250,7 @@ extension DataBrokerProtectionWebViewHandler: WKNavigationDelegate {
}

if statusCode >= 400 {
Logger.action.debug("WebViewHandler failed with status code: \(String(describing: statusCode), privacy: .public)")
Logger.action.log("WebViewHandler failed with status code: \(String(describing: statusCode), privacy: .public)")
self.activeContinuation?.resume(throwing: DataBrokerProtectionError.httpError(code: statusCode))
self.activeContinuation = nil
}
Expand Down Expand Up @@ -289,6 +289,6 @@ private class WebView: WKWebView {

deinit {
configuration.userContentController.removeAllUserScripts()
Logger.action.debug("DBP WebView Deinit")
Logger.action.log("DBP WebView Deinit")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public class DataBrokerProtectionDataManager: DataBrokerProtectionDataManaging {

public func fetchProfile() throws -> DataBrokerProtectionProfile? {
if cache.profile != nil {
Logger.dataBrokerProtection.debug("Returning cached profile")
Logger.dataBrokerProtection.log("Returning cached profile")
return cache.profile
}

Expand All @@ -114,7 +114,7 @@ public class DataBrokerProtectionDataManager: DataBrokerProtectionDataManaging {
cache.profile = profile
return profile
} else {
Logger.dataBrokerProtection.debug("No profile found")
Logger.dataBrokerProtection.log("No profile found")
return nil
}
}
Expand All @@ -123,13 +123,13 @@ public class DataBrokerProtectionDataManager: DataBrokerProtectionDataManaging {
if let profile = try database.fetchProfile() {
cache.profile = profile
} else {
Logger.dataBrokerProtection.debug("No profile found")
Logger.dataBrokerProtection.log("No profile found")
}
}

public func fetchBrokerProfileQueryData(ignoresCache: Bool = false) throws -> [BrokerProfileQueryData] {
if !ignoresCache, !cache.brokerProfileQueryData.isEmpty {
Logger.dataBrokerProtection.debug("Returning cached brokerProfileQueryData")
Logger.dataBrokerProtection.log("Returning cached brokerProfileQueryData")
return cache.brokerProfileQueryData
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ final class DataBrokerRunCustomJSONViewModel: ObservableObject {
let fileURL = URL(fileURLWithPath: "\(path)/\(fileName)")
try csv.write(to: fileURL, atomically: true, encoding: .utf8)
} else {
Logger.dataBrokerProtection.debug("Error getting path")
Logger.dataBrokerProtection.error("Error getting path")
}
} catch {
Logger.dataBrokerProtection.error("Error writing to file: \(error)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,6 @@ final class DataBrokerJobRunner: WebJobRunner {
}

deinit {
Logger.dataBrokerProtection.debug("WebOperationRunner Deinit")
Logger.dataBrokerProtection.log("WebOperationRunner Deinit")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class DataBrokerOperation: Operation, @unchecked Sendable {
private var _isFinished = false

deinit {
Logger.dataBrokerProtection.debug("Deinit operation: \(String(describing: self.id.uuidString), privacy: .public)")
Logger.dataBrokerProtection.log("Deinit operation: \(String(describing: self.id.uuidString), privacy: .public)")
}

init(dataBrokerID: Int64,
Expand Down Expand Up @@ -156,11 +156,11 @@ class DataBrokerOperation: Operation, @unchecked Sendable {
operationType: operationType,
priorityDate: priorityDate)

Logger.dataBrokerProtection.debug("filteredAndSortedOperationsData count: \(filteredAndSortedOperationsData.count, privacy: .public) for brokerID \(self.dataBrokerID, privacy: .public)")
Logger.dataBrokerProtection.log("filteredAndSortedOperationsData count: \(filteredAndSortedOperationsData.count, privacy: .public) for brokerID \(self.dataBrokerID, privacy: .public)")

for operationData in filteredAndSortedOperationsData {
if isCancelled {
Logger.dataBrokerProtection.debug("Cancelled operation, returning...")
Logger.dataBrokerProtection.log("Cancelled operation, returning...")
return
}

Expand All @@ -172,7 +172,7 @@ class DataBrokerOperation: Operation, @unchecked Sendable {
continue
}
do {
Logger.dataBrokerProtection.debug("Running operation: \(String(describing: operationData), privacy: .public)")
Logger.dataBrokerProtection.log("Running operation: \(String(describing: operationData), privacy: .public)")

try await DataBrokerProfileQueryOperationManager().runOperation(operationData: operationData,
brokerProfileQueryData: brokerProfileData,
Expand All @@ -189,7 +189,7 @@ class DataBrokerOperation: Operation, @unchecked Sendable {
})

let sleepInterval = operationDependencies.config.intervalBetweenSameBrokerOperations
Logger.dataBrokerProtection.debug("Waiting...: \(sleepInterval, privacy: .public)")
Logger.dataBrokerProtection.log("Waiting...: \(sleepInterval, privacy: .public)")
try await Task.sleep(nanoseconds: UInt64(sleepInterval) * 1_000_000_000)
} catch {
Logger.dataBrokerProtection.error("Error: \(error.localizedDescription, privacy: .public)")
Expand All @@ -211,7 +211,7 @@ class DataBrokerOperation: Operation, @unchecked Sendable {
didChangeValue(forKey: #keyPath(isExecuting))
didChangeValue(forKey: #keyPath(isFinished))

Logger.dataBrokerProtection.debug("Finished operation: \(self.id.uuidString, privacy: .public)")
Logger.dataBrokerProtection.log("Finished operation: \(self.id.uuidString, privacy: .public)")
}
}
// swiftlint:enable explicit_non_final_class
Loading

0 comments on commit 7fcd3e5

Please sign in to comment.