From a8b0e8700e8b01ef8ab86f050c2df2fb3446109b Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Thu, 3 Jun 2021 11:30:07 +0300 Subject: [PATCH] Adopt consolidated logging mechanism (#4370) * Adopted the new MXLog and replaced NSLog throughout the application - vector-im/element-ios/issues/4351 * Replaced NSLog() and print() usages with MXLog.debug() * Added swiftlint rules for NSLog(), print(), println() and os_log() * Escape paths used to run script build phases for swiftlint and swiftgen --- .swiftlint.yml | 28 ++ CHANGES.rst | 1 + .../MXKRoomBubbleTableViewCell+Riot.m | 2 +- Riot/Categories/MXRoom+Riot.m | 8 +- .../Categories/UNUserNotificationCenter.swift | 5 +- Riot/Managers/Analytics/Analytics.m | 2 +- .../Analytics/DecryptionFailureTracker.m | 2 +- Riot/Managers/BugReport/RageShakeManager.m | 4 +- Riot/Managers/Call/CallPresenter.swift | 80 +++--- .../EncryptionKeyManager.swift | 4 +- .../OnBoarding/OnBoardingManager.swift | 4 +- .../PushNotificationService.m | 60 ++--- .../PushNotificationStore.swift | 4 +- .../UserSessions/UserSessionsService.swift | 6 +- Riot/Managers/Widgets/Widget.m | 2 +- Riot/Managers/Widgets/WidgetManager.m | 34 +-- .../HomeserverConfigurationBuilder.swift | 10 +- .../WellKnown/VectorWellKnownParser.swift | 2 +- Riot/Modules/Application/AppCoordinator.swift | 6 +- Riot/Modules/Application/LegacyAppDelegate.m | 249 +++++++++--------- .../AuthenticationViewController.m | 40 +-- .../SSO/SSOAuthenticationPresenter.swift | 2 +- .../Authentication/Views/AuthInputsView.m | 76 +++--- .../Views/ForgotPasswordInputsView.m | 16 +- Riot/Modules/Call/CallViewController.m | 6 +- .../Camera/CameraAccessAlertPresenter.swift | 2 +- .../RiotNavigationController.m | 4 +- .../Recents/DataSources/RecentsDataSource.m | 18 +- .../Common/Recents/RecentsViewController.m | 14 +- .../Home/GroupHomeViewController.m | 12 +- .../Members/GroupParticipantsViewController.m | 10 +- .../Rooms/GroupRoomsViewController.m | 2 +- .../Contacts/DataSources/ContactsDataSource.m | 2 +- .../Details/ContactDetailsViewController.m | 8 +- .../GDPR/GDPRConsentViewController.swift | 2 +- .../Fallback/AuthFallBackViewController.m | 2 +- .../IntegrationManagerViewController.m | 28 +- .../WidgetPicker/WidgetPickerViewController.m | 4 +- .../Widgets/Jitsi/JitsiService.swift | 4 +- .../Widgets/Jitsi/JitsiViewController.m | 6 +- .../Widgets/WidgetViewController.m | 30 +-- ...kupRecoverCoordinatorBridgePresenter.swift | 2 +- ...RecoverFromRecoveryKeyViewController.swift | 2 +- .../Common/KeyVerificationCoordinator.swift | 4 +- ...rificationCoordinatorBridgePresenter.swift | 14 +- .../KeyVerificationDataLoadingViewModel.swift | 2 +- ...erificationVerifyByScanningViewModel.swift | 4 +- ...yVerificationSelfVerifyWaitViewModel.swift | 4 +- .../MajorUpdate/MajorUpdateManager.swift | 4 +- .../Library/MediaAlbumContentViewController.m | 2 +- .../MediaPicker/MediaPickerViewController.m | 20 +- .../PublicRoomsDirectoryDataSource.m | 2 +- .../ReauthenticationCoordinator.swift | 2 +- .../Room/CellData/RoomBubbleCellData.m | 6 +- .../Modules/Room/DataSources/RoomDataSource.m | 6 +- ...ditHistoryCoordinatorBridgePresenter.swift | 2 +- .../EditHistory/EditHistoryViewModel.swift | 8 +- .../Data/EmojiMart/EmojiJSONStore.swift | 2 +- .../Data/EmojiMart/EmojiMartStore.swift | 2 +- .../Detail/RoomMemberDetailsViewController.m | 4 +- .../Members/RoomParticipantsViewController.m | 12 +- .../ReactionHistoryViewModel.swift | 4 +- Riot/Modules/Room/RoomViewController.m | 58 ++-- .../Settings/RoomSettingsViewController.m | 40 +-- .../Group/RoomGroupCallStatusBubbleCell.swift | 2 +- .../KeyVerificationConclusionBubbleCell.swift | 2 +- ...ionIncomingRequestApprovalBubbleCell.swift | 2 +- ...yVerificationRequestStatusBubbleCell.swift | 8 +- .../RoomCreationIntroCell.swift | 8 +- .../Title/Expanded/ExpandedRoomTitleView.m | 2 +- .../Title/Preview/PreviewRoomTitleView.m | 2 +- ...SecretsRecoveryWithKeyViewController.swift | 2 +- ...tsRecoveryCoordinatorBridgePresenter.swift | 2 +- .../Secrets/Reset/SecretsResetViewModel.swift | 2 +- .../ServiceTermsModalScreenViewModel.swift | 2 +- .../SetPinCode/PinCodePreferences.swift | 21 +- .../DeactivateAccountViewController.m | 6 +- .../SettingsIdentityServerViewModel.swift | 4 +- .../ManageSessionViewController.m | 6 +- .../Security/SecurityViewController.m | 2 +- .../Modules/Settings/SettingsViewController.m | 30 +-- .../SlidingModal/SlidingModalPresenter.swift | 4 +- .../SplitView/SplitViewCoordinator.swift | 4 +- .../StartChat/StartChatViewController.m | 6 +- Riot/Modules/TabBar/MasterTabBarController.m | 18 +- Riot/Modules/TabBar/TabBarCoordinator.swift | 4 +- .../UserDevices/Views/DeviceTableViewCell.m | 2 +- Riot/Routers/NavigationRouter.swift | 16 +- Riot/target.yml | 4 +- RiotNSE/NotificationService.swift | 83 +++--- .../Managers/ShareExtensionManager.m | 49 ++-- .../Share/DataSources/ShareDataSource.m | 2 +- .../Share/Listing/RoomsListViewController.m | 2 +- SiriIntents/IntentHandler.m | 15 +- 94 files changed, 689 insertions(+), 630 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index 45694f160..8682b5912 100755 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -63,3 +63,31 @@ type_name: max_length: # warning and error warning: 150 error: 1000 + +custom_rules: + ns_log_deprecation: + regex: "\\b(NSLog)\\b" + match_kinds: identifier + message: "MXLog should be used instead of NSLog()" + severity: error + + print_deprecation: + regex: "\\b(print)\\b" + match_kinds: identifier + message: "MXLog should be used instead of print()" + severity: error + + print_ln_deprecation: + regex: "\\b(println)\\b" + match_kinds: identifier + message: "MXLog should be used instead of println()" + severity: error + + os_log_deprecation: + regex: "\\b(os_log)\\b" + match_kinds: identifier + message: "MXLog should be used instead of os_log()" + severity: error + + + diff --git a/CHANGES.rst b/CHANGES.rst index a22c056b2..a30fcd352 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -9,6 +9,7 @@ Changes to be released in next version * Navigation: Start decoupling view controllers managed by MasterTabBarController (#3596 and #3618). * Jitsi: Include optional server name field on JitsiJWTPayloadContextMatrix. * CallPresenter: Add more logs for group calls. + * Logging: Adopted MXLog throughout the application (vector-im/element-ios/issues/4351). 🐛 Bugfix * buildRelease.sh: Make bundler operations in the cloned repository folder. diff --git a/Riot/Categories/MXKRoomBubbleTableViewCell+Riot.m b/Riot/Categories/MXKRoomBubbleTableViewCell+Riot.m index ade4a3c1c..a85ea69be 100644 --- a/Riot/Categories/MXKRoomBubbleTableViewCell+Riot.m +++ b/Riot/Categories/MXKRoomBubbleTableViewCell+Riot.m @@ -80,7 +80,7 @@ NSString *const kMXKRoomBubbleCellKeyVerificationIncomingRequestDeclinePressed = { if (!self.bubbleInfoContainer) { - NSLog(@"[MXKRoomBubbleTableViewCell+Riot] bubbleInfoContainer property is missing for cell class: %@", NSStringFromClass(self.class)); + MXLogDebug(@"[MXKRoomBubbleTableViewCell+Riot] bubbleInfoContainer property is missing for cell class: %@", NSStringFromClass(self.class)); return; } diff --git a/Riot/Categories/MXRoom+Riot.m b/Riot/Categories/MXRoom+Riot.m index de4d67a54..273f86a82 100644 --- a/Riot/Categories/MXRoom+Riot.m +++ b/Riot/Categories/MXRoom+Riot.m @@ -43,7 +43,7 @@ NSString* tagOrder = [self.mxSession tagOrderToBeAtIndex:0 from:NSNotFound withTag:tag]; - NSLog(@"[MXRoom+Riot] Update the room %@ tag from %@ to %@ with tag order %@", self.roomId, oldTag, tag, tagOrder); + MXLogDebug(@"[MXRoom+Riot] Update the room %@ tag from %@ to %@ with tag order %@", self.roomId, oldTag, tag, tagOrder); [self replaceTag:oldTag byTag:tag @@ -57,7 +57,7 @@ } failure:^(NSError *error) { - NSLog(@"[MXRoom+Riot] Failed to update the tag %@ of room (%@)", tag, self.roomId); + MXLogDebug(@"[MXRoom+Riot] Failed to update the tag %@ of room (%@)", tag, self.roomId); NSString *userId = self.mxSession.myUser.userId; // Notify user @@ -166,7 +166,7 @@ // Check whether there is no pending update for this room if (self.notificationCenterDidUpdateObserver) { - NSLog(@"[MXRoom+Riot] Request in progress: ignore push rule update"); + MXLogDebug(@"[MXRoom+Riot] Request in progress: ignore push rule update"); if (completion) { completion(); @@ -244,7 +244,7 @@ // Check whether there is no pending update for this room if (self.notificationCenterDidUpdateObserver) { - NSLog(@"[MXRoom+Riot] Request in progress: ignore push rule update"); + MXLogDebug(@"[MXRoom+Riot] Request in progress: ignore push rule update"); if (completion) { completion(); diff --git a/Riot/Categories/UNUserNotificationCenter.swift b/Riot/Categories/UNUserNotificationCenter.swift index d11fb60f2..2f21dfdeb 100644 --- a/Riot/Categories/UNUserNotificationCenter.swift +++ b/Riot/Categories/UNUserNotificationCenter.swift @@ -16,6 +16,7 @@ import Foundation import UserNotifications +import MatrixSDK @objc extension UNUserNotificationCenter { @@ -24,7 +25,7 @@ import UserNotifications // get identifiers of notifications whose category identifiers are "TO_BE_REMOVED" let identifiersToBeRemoved = notifications.compactMap({ $0.request.content.categoryIdentifier == Constants.toBeRemovedNotificationCategoryIdentifier ? $0.request.identifier : nil }) - NSLog("[UNUserNotificationCenter] removeUnwantedNotifications: Removing \(identifiersToBeRemoved.count) notifications.") + MXLog.debug("[UNUserNotificationCenter] removeUnwantedNotifications: Removing \(identifiersToBeRemoved.count) notifications.") // remove the notifications with these id's UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: identifiersToBeRemoved) } @@ -52,7 +53,7 @@ import UserNotifications // get identifiers of notifications that should be removed let identifiersToBeRemoved = notifications.compactMap({ notificationShouldBeRemoved($0) ? $0.request.identifier : nil }) - NSLog("[UNUserNotificationCenter] removeCallNotifications: Removing \(identifiersToBeRemoved.count) notifications.") + MXLog.debug("[UNUserNotificationCenter] removeCallNotifications: Removing \(identifiersToBeRemoved.count) notifications.") // remove the notifications with these id's UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: identifiersToBeRemoved) } diff --git a/Riot/Managers/Analytics/Analytics.m b/Riot/Managers/Analytics/Analytics.m index 2786f0964..fc7c3576c 100644 --- a/Riot/Managers/Analytics/Analytics.m +++ b/Riot/Managers/Analytics/Analytics.m @@ -109,7 +109,7 @@ NSString *const kAnalyticsMetricsCategory = @"Metrics"; } else { - NSLog(@"[AppDelegate] The user decided to not send analytics"); + MXLogDebug(@"[AppDelegate] The user decided to not send analytics"); matomoTracker.isOptedOut = YES; [MXLogger logCrashes:NO]; } diff --git a/Riot/Managers/Analytics/DecryptionFailureTracker.m b/Riot/Managers/Analytics/DecryptionFailureTracker.m index 023976500..56521eb58 100644 --- a/Riot/Managers/Analytics/DecryptionFailureTracker.m +++ b/Riot/Managers/Analytics/DecryptionFailureTracker.m @@ -158,7 +158,7 @@ NSString *const kDecryptionFailureTrackerAnalyticsCategory = @"e2e.failure"; failuresCounts[failure.reason] = @(failuresCounts[failure.reason].unsignedIntegerValue + 1); } - NSLog(@"[DecryptionFailureTracker] trackFailures: %@", failuresCounts); + MXLogDebug(@"[DecryptionFailureTracker] trackFailures: %@", failuresCounts); for (NSString *reason in failuresCounts) { diff --git a/Riot/Managers/BugReport/RageShakeManager.m b/Riot/Managers/BugReport/RageShakeManager.m index 2a647cc95..10edcfb75 100644 --- a/Riot/Managers/BugReport/RageShakeManager.m +++ b/Riot/Managers/BugReport/RageShakeManager.m @@ -115,7 +115,7 @@ static RageShakeManager* sharedInstance = nil; && RiotSettings.shared.enableRageShake && !confirmationAlert) { - NSLog(@"[RageShakeManager] Start shaking with [%@]", [responder class]); + MXLogDebug(@"[RageShakeManager] Start shaking with [%@]", [responder class]); startShakingTimeStamp = [[NSDate date] timeIntervalSince1970]; isShaking = YES; @@ -124,7 +124,7 @@ static RageShakeManager* sharedInstance = nil; - (void)stopShaking:(UIResponder*)responder { - NSLog(@"[RageShakeManager] Stop shaking with [%@]", [responder class]); + MXLogDebug(@"[RageShakeManager] Stop shaking with [%@]", [responder class]); if (isShaking && [AppDelegate theDelegate].isAppForeground && !confirmationAlert && (([[NSDate date] timeIntervalSince1970] - startShakingTimeStamp) > RAGESHAKEMANAGER_MINIMUM_SHAKING_DURATION)) diff --git a/Riot/Managers/Call/CallPresenter.swift b/Riot/Managers/Call/CallPresenter.swift index c4ea57ae5..e3b4f6e31 100644 --- a/Riot/Managers/Call/CallPresenter.swift +++ b/Riot/Managers/Call/CallPresenter.swift @@ -118,7 +118,7 @@ class CallPresenter: NSObject { /// Start the service func start() { - NSLog("[CallPresenter] start") + MXLog.debug("[CallPresenter] start") addCallObservers() startCallTimer() @@ -126,7 +126,7 @@ class CallPresenter: NSObject { /// Stop the service func stop() { - NSLog("[CallPresenter] stop") + MXLog.debug("[CallPresenter] stop") removeCallObservers() stopCallTimer() @@ -134,7 +134,7 @@ class CallPresenter: NSObject { /// Method to be called when the call status bar is tapped. func callStatusBarTapped() { - NSLog("[CallPresenter] callStatusBarTapped") + MXLog.debug("[CallPresenter] callStatusBarTapped") if let callVC = (inBarCallVC ?? activeCallVC) as? CallViewController { dismissCallBar(for: callVC) @@ -152,7 +152,7 @@ class CallPresenter: NSObject { /// Open the Jitsi view controller from a widget. /// - Parameter widget: the jitsi widget func displayJitsiCall(withWidget widget: Widget) { - NSLog("[CallPresenter] displayJitsiCall: for widget: \(widget.widgetId)") + MXLog.debug("[CallPresenter] displayJitsiCall: for widget: \(widget.widgetId)") #if canImport(JitsiMeetSDK) let createJitsiBlock = { [weak self] in @@ -191,26 +191,26 @@ class CallPresenter: NSObject { } private func startJitsiCall(withWidget widget: Widget) { - NSLog("[CallPresenter] startJitsiCall") + MXLog.debug("[CallPresenter] startJitsiCall") if let uuid = self.jitsiCalls.first(where: { $0.value.widgetId == widget.widgetId })?.key { // this Jitsi call is already managed by this class, no need to report the call again - NSLog("[CallPresenter] startJitsiCall: already managed with id: \(uuid.uuidString)") + MXLog.debug("[CallPresenter] startJitsiCall: already managed with id: \(uuid.uuidString)") return } guard let roomId = widget.roomId else { - NSLog("[CallPresenter] startJitsiCall: no roomId on widget") + MXLog.debug("[CallPresenter] startJitsiCall: no roomId on widget") return } guard let session = sessions.first else { - NSLog("[CallPresenter] startJitsiCall: no active session") + MXLog.debug("[CallPresenter] startJitsiCall: no active session") return } guard let room = session.room(withRoomId: roomId) else { - NSLog("[CallPresenter] startJitsiCall: unknown room: \(roomId)") + MXLog.debug("[CallPresenter] startJitsiCall: unknown room: \(roomId)") return } @@ -219,10 +219,10 @@ class CallPresenter: NSObject { let startCallAction = CXStartCallAction(call: newUUID, handle: handle) let transaction = CXTransaction(action: startCallAction) - NSLog("[CallPresenter] startJitsiCall: new call with id: \(newUUID.uuidString)") + MXLog.debug("[CallPresenter] startJitsiCall: new call with id: \(newUUID.uuidString)") JMCallKitProxy.request(transaction) { (error) in - NSLog("[CallPresenter] startJitsiCall: JMCallKitProxy returned \(String(describing: error))") + MXLog.debug("[CallPresenter] startJitsiCall: JMCallKitProxy returned \(String(describing: error))") if error == nil { JMCallKitProxy.reportCallUpdate(with: newUUID, @@ -237,11 +237,11 @@ class CallPresenter: NSObject { } func endActiveJitsiCall() { - NSLog("[CallPresenter] endActiveJitsiCall") + MXLog.debug("[CallPresenter] endActiveJitsiCall") guard let jitsiVC = jitsiVC else { // there is no active Jitsi call - NSLog("[CallPresenter] endActiveJitsiCall: no active Jitsi call") + MXLog.debug("[CallPresenter] endActiveJitsiCall: no active Jitsi call") return } @@ -257,22 +257,22 @@ class CallPresenter: NSObject { self.jitsiVC = nil guard let widget = jitsiVC.widget else { - NSLog("[CallPresenter] endActiveJitsiCall: no Jitsi widget for the active call") + MXLog.debug("[CallPresenter] endActiveJitsiCall: no Jitsi widget for the active call") return } guard let uuid = self.jitsiCalls.first(where: { $0.value.widgetId == widget.widgetId })?.key else { // this Jitsi call is not managed by this class - NSLog("[CallPresenter] endActiveJitsiCall: Not managed Jitsi call: \(widget.widgetId)") + MXLog.debug("[CallPresenter] endActiveJitsiCall: Not managed Jitsi call: \(widget.widgetId)") return } let endCallAction = CXEndCallAction(call: uuid) let transaction = CXTransaction(action: endCallAction) - NSLog("[CallPresenter] endActiveJitsiCall: ended call with id: \(uuid.uuidString)") + MXLog.debug("[CallPresenter] endActiveJitsiCall: ended call with id: \(uuid.uuidString)") JMCallKitProxy.request(transaction) { (error) in - NSLog("[CallPresenter] endActiveJitsiCall: JMCallKitProxy returned \(String(describing: error))") + MXLog.debug("[CallPresenter] endActiveJitsiCall: JMCallKitProxy returned \(String(describing: error))") if error == nil { self.jitsiCalls.removeValue(forKey: uuid) } @@ -280,42 +280,42 @@ class CallPresenter: NSObject { } func processWidgetEvent(_ event: MXEvent, inSession session: MXSession) { - NSLog("[CallPresenter] processWidgetEvent") + MXLog.debug("[CallPresenter] processWidgetEvent") guard JMCallKitProxy.isProviderConfigured() else { // CallKit proxy is not configured, no benefit in parsing the event - NSLog("[CallPresenter] processWidgetEvent: JMCallKitProxy not configured") + MXLog.debug("[CallPresenter] processWidgetEvent: JMCallKitProxy not configured") return } guard let widget = Widget(widgetEvent: event, inMatrixSession: session) else { - NSLog("[CallPresenter] processWidgetEvent: widget couldn't be created") + MXLog.debug("[CallPresenter] processWidgetEvent: widget couldn't be created") return } if let uuid = self.jitsiCalls.first(where: { $0.value.widgetId == widget.widgetId })?.key { // this Jitsi call is already managed by this class, no need to report the call again - NSLog("[CallPresenter] processWidgetEvent: Jitsi call already managed with id: \(uuid.uuidString)") + MXLog.debug("[CallPresenter] processWidgetEvent: Jitsi call already managed with id: \(uuid.uuidString)") return } if widget.isActive { guard widget.type == kWidgetTypeJitsiV1 || widget.type == kWidgetTypeJitsiV2 else { // not a Jitsi widget, ignore - NSLog("[CallPresenter] processWidgetEvent: not a Jitsi widget") + MXLog.debug("[CallPresenter] processWidgetEvent: not a Jitsi widget") return } if let jitsiVC = jitsiVC, jitsiVC.widget.widgetId == widget.widgetId { // this is already the Jitsi call we have atm - NSLog("[CallPresenter] processWidgetEvent: ongoing Jitsi call") + MXLog.debug("[CallPresenter] processWidgetEvent: ongoing Jitsi call") return } if TimeInterval(event.age)/MSEC_PER_SEC > Constants.groupCallInviteLifetime { // too late to process the event - NSLog("[CallPresenter] processWidgetEvent: expired call invite") + MXLog.debug("[CallPresenter] processWidgetEvent: expired call invite") return } @@ -327,7 +327,7 @@ class CallPresenter: NSObject { if event.sender == session.myUserId { // outgoing call - NSLog("[CallPresenter] processWidgetEvent: Report outgoing call with id: \(newUUID.uuidString)") + MXLog.debug("[CallPresenter] processWidgetEvent: Report outgoing call with id: \(newUUID.uuidString)") JMCallKitProxy.reportOutgoingCall(with: newUUID, connectedAt: nil) } else { // incoming call @@ -339,13 +339,13 @@ class CallPresenter: NSObject { let displayName = NSString.localizedUserNotificationString(forKey: "GROUP_CALL_FROM_USER", arguments: [user?.displayname as Any]) - NSLog("[CallPresenter] processWidgetEvent: Report new incoming call with id: \(newUUID.uuidString)") + MXLog.debug("[CallPresenter] processWidgetEvent: Report new incoming call with id: \(newUUID.uuidString)") JMCallKitProxy.reportNewIncomingCall(UUID: newUUID, handle: widget.roomId, displayName: displayName, hasVideo: true) { (error) in - NSLog("[CallPresenter] processWidgetEvent: JMCallKitProxy returned \(String(describing: error))") + MXLog.debug("[CallPresenter] processWidgetEvent: JMCallKitProxy returned \(String(describing: error))") if error != nil { self.jitsiCalls.removeValue(forKey: newUUID) @@ -355,10 +355,10 @@ class CallPresenter: NSObject { } else { guard let uuid = self.jitsiCalls.first(where: { $0.value.widgetId == widget.widgetId })?.key else { // this Jitsi call is not managed by this class - NSLog("[CallPresenter] processWidgetEvent: not managed Jitsi call: \(widget.widgetId)") + MXLog.debug("[CallPresenter] processWidgetEvent: not managed Jitsi call: \(widget.widgetId)") return } - NSLog("[CallPresenter] processWidgetEvent: ended call with id: \(uuid.uuidString)") + MXLog.debug("[CallPresenter] processWidgetEvent: ended call with id: \(uuid.uuidString)") JMCallKitProxy.reportCall(with: uuid, endedAt: nil, reason: .remoteEnded) self.jitsiCalls.removeValue(forKey: uuid) } @@ -440,9 +440,9 @@ class CallPresenter: NSObject { private func logCallVC(_ callVC: UIViewController, log: String) { if let callVC = callVC as? CallViewController { - NSLog("[CallPresenter] \(log): Matrix call: \(String(describing: callVC.mxCall?.callId))") + MXLog.debug("[CallPresenter] \(log): Matrix call: \(String(describing: callVC.mxCall?.callId))") } else if let callVC = callVC as? JitsiViewController { - NSLog("[CallPresenter] \(log): Jitsi call: \(callVC.widget.widgetId)") + MXLog.debug("[CallPresenter] \(log): Jitsi call: \(callVC.widget.widgetId)") } } @@ -608,23 +608,23 @@ class CallPresenter: NSObject { switch call.state { case .createAnswer: - NSLog("[CallPresenter] callStateChanged: call created answer: \(call.callId)") + MXLog.debug("[CallPresenter] callStateChanged: call created answer: \(call.callId)") if call.isIncoming, isCallKitEnabled, let callVC = callVCs[call.callId] { presentCallVC(callVC) } case .connected: - NSLog("[CallPresenter] callStateChanged: call connected: \(call.callId)") + MXLog.debug("[CallPresenter] callStateChanged: call connected: \(call.callId)") callTimer?.fire() case .onHold: - NSLog("[CallPresenter] callStateChanged: call holded: \(call.callId)") + MXLog.debug("[CallPresenter] callStateChanged: call holded: \(call.callId)") callTimer?.fire() callHolded(withCallId: call.callId) case .remotelyOnHold: - NSLog("[CallPresenter] callStateChanged: call remotely holded: \(call.callId)") + MXLog.debug("[CallPresenter] callStateChanged: call remotely holded: \(call.callId)") callTimer?.fire() callHolded(withCallId: call.callId) case .ended: - NSLog("[CallPresenter] callStateChanged: call ended: \(call.callId)") + MXLog.debug("[CallPresenter] callStateChanged: call ended: \(call.callId)") endCall(withCallId: call.callId) default: break @@ -633,7 +633,7 @@ class CallPresenter: NSObject { @objc private func callTileTapped(_ notification: Notification) { - NSLog("[CallPresenter] callTileTapped") + MXLog.debug("[CallPresenter] callTileTapped") guard let bubbleData = notification.object as? RoomBubbleCellData else { return @@ -647,7 +647,7 @@ class CallPresenter: NSObject { return } - NSLog("[CallPresenter] callTileTapped: for call: \(callEventContent.callId)") + MXLog.debug("[CallPresenter] callTileTapped: for call: \(callEventContent.callId)") guard let session = sessions.first else { return } @@ -672,7 +672,7 @@ class CallPresenter: NSObject { @objc private func groupCallTileTapped(_ notification: Notification) { - NSLog("[CallPresenter] groupCallTileTapped") + MXLog.debug("[CallPresenter] groupCallTileTapped") guard let bubbleData = notification.object as? RoomBubbleCellData else { return @@ -694,7 +694,7 @@ class CallPresenter: NSObject { return } - NSLog("[CallPresenter] groupCallTileTapped: for call: \(widget.widgetId)") + MXLog.debug("[CallPresenter] groupCallTileTapped: for call: \(widget.widgetId)") guard let jitsiVC = jitsiVC, jitsiVC.widget.widgetId == widget.widgetId else { diff --git a/Riot/Managers/EncryptionKeyManager/EncryptionKeyManager.swift b/Riot/Managers/EncryptionKeyManager/EncryptionKeyManager.swift index d45e2f2dd..168dad3cb 100644 --- a/Riot/Managers/EncryptionKeyManager/EncryptionKeyManager.swift +++ b/Riot/Managers/EncryptionKeyManager/EncryptionKeyManager.swift @@ -104,7 +104,7 @@ class EncryptionKeyManager: NSObject, MXKeyProviderDelegate { do { try keychainStore.set(MXAes.iv(), forKey: key) } catch { - NSLog("[EncryptionKeyManager] initKeys: Failed to generate IV: %@", error.localizedDescription) + MXLog.debug("[EncryptionKeyManager] initKeys: Failed to generate IV: \(error.localizedDescription)") } } @@ -122,7 +122,7 @@ class EncryptionKeyManager: NSObject, MXKeyProviderDelegate { _ = SecRandomCopyBytes(kSecRandomDefault, size, &keyBytes) try keychainStore.set(Data(bytes: keyBytes, count: size), forKey: key) } catch { - NSLog("[EncryptionKeyManager] initKeys: Failed to generate Key[%@]: %@", key, error.localizedDescription) + MXLog.debug("[EncryptionKeyManager] initKeys: Failed to generate Key[\(key)]: \(error.localizedDescription)") } } } diff --git a/Riot/Managers/OnBoarding/OnBoardingManager.swift b/Riot/Managers/OnBoarding/OnBoardingManager.swift index f224383d4..c2016019f 100644 --- a/Riot/Managers/OnBoarding/OnBoardingManager.swift +++ b/Riot/Managers/OnBoarding/OnBoardingManager.swift @@ -63,7 +63,7 @@ final public class OnBoardingManager: NSObject { case .success: success?() case .failure(let error): - NSLog("[OnBoardingManager] Create chat with riot-bot failed") + MXLog.debug("[OnBoardingManager] Create chat with riot-bot failed") failure?(error) } } @@ -72,7 +72,7 @@ final public class OnBoardingManager: NSObject { httpOperation.maxNumberOfTries = Constants.createRiotBotDMRequestMaxNumberOfTries case .failure(let error): - NSLog("[OnBoardingManager] riot-bot is unknown or the user hs is non federated. Do not try to create a room with riot-bot") + MXLog.debug("[OnBoardingManager] riot-bot is unknown or the user hs is non federated. Do not try to create a room with riot-bot") failure?(error) } } diff --git a/Riot/Managers/PushNotification/PushNotificationService.m b/Riot/Managers/PushNotification/PushNotificationService.m index 530fc53ce..350cd564f 100644 --- a/Riot/Managers/PushNotification/PushNotificationService.m +++ b/Riot/Managers/PushNotification/PushNotificationService.m @@ -54,7 +54,7 @@ Matrix session observer used to detect new opened sessions. - (void)registerUserNotificationSettings { - NSLog(@"[PushNotificationService][Push] registerUserNotificationSettings: isPushRegistered: %@", @(_isPushRegistered)); + MXLogDebug(@"[PushNotificationService][Push] registerUserNotificationSettings: isPushRegistered: %@", @(_isPushRegistered)); if (!_isPushRegistered) { @@ -103,7 +103,7 @@ Matrix session observer used to detect new opened sessions. - (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { - NSLog(@"[PushNotificationService][Push] didRegisterForRemoteNotificationsWithDeviceToken"); + MXLogDebug(@"[PushNotificationService][Push] didRegisterForRemoteNotificationsWithDeviceToken"); MXKAccountManager* accountManager = [MXKAccountManager sharedManager]; [accountManager setApnsDeviceToken:deviceToken]; @@ -115,7 +115,7 @@ Matrix session observer used to detect new opened sessions. NSString *pushDeviceToken = [MXKAppSettings.standardAppSettings.sharedUserDefaults objectForKey:@"pushDeviceToken"]; if (pushDeviceToken) { - NSLog(@"[PushNotificationService][Push] didRegisterForRemoteNotificationsWithDeviceToken: Move PushKit token to user defaults"); + MXLogDebug(@"[PushNotificationService][Push] didRegisterForRemoteNotificationsWithDeviceToken: Move PushKit token to user defaults"); // Set the token in standard user defaults, as MXKAccount will read it from there when removing the pusher. // This will allow to remove the PushKit pusher in the next step @@ -129,7 +129,7 @@ Matrix session observer used to detect new opened sessions. // If we already have pushDeviceToken or recovered it in above step, remove its PushKit pusher if (accountManager.pushDeviceToken) { - NSLog(@"[PushNotificationService][Push] didRegisterForRemoteNotificationsWithDeviceToken: A PushKit pusher still exists. Remove it"); + MXLogDebug(@"[PushNotificationService][Push] didRegisterForRemoteNotificationsWithDeviceToken: A PushKit pusher still exists. Remove it"); // Attempt to remove PushKit pushers explicitly [self clearPushNotificationToken]; @@ -163,7 +163,7 @@ Matrix session observer used to detect new opened sessions. - (void)didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { - NSLog(@"[PushNotificationService][Push] didReceiveRemoteNotification: applicationState: %tu - payload: %@", [UIApplication sharedApplication].applicationState, userInfo); + MXLogDebug(@"[PushNotificationService][Push] didReceiveRemoteNotification: applicationState: %tu - payload: %@", [UIApplication sharedApplication].applicationState, userInfo); completionHandler(UIBackgroundFetchResultNewData); } @@ -202,11 +202,11 @@ Matrix session observer used to detect new opened sessions. { [session.matrixRestClient pushers:^(NSArray *pushers) { - NSLog(@"[PushNotificationService][Push] checkPushKitPushers: %@ has %@ pushers:", session.myUserId, @(pushers.count)); + MXLogDebug(@"[PushNotificationService][Push] checkPushKitPushers: %@ has %@ pushers:", session.myUserId, @(pushers.count)); for (MXPusher *pusher in pushers) { - NSLog(@" - %@", pusher.appId); + MXLogDebug(@" - %@", pusher.appId); // We do not want anymore PushKit pushers the app used to use if ([pusher.appId isEqualToString:BuildSettings.pushKitAppIdProd] @@ -216,7 +216,7 @@ Matrix session observer used to detect new opened sessions. } } } failure:^(NSError *error) { - NSLog(@"[PushNotificationService][Push] checkPushKitPushers: Error: %@", error); + MXLogDebug(@"[PushNotificationService][Push] checkPushKitPushers: Error: %@", error); }]; } @@ -268,7 +268,7 @@ Matrix session observer used to detect new opened sessions. - (void)removePusher:(MXPusher*)pusher inSession:(MXSession*)session { - NSLog(@"[PushNotificationService][Push] removePusher: %@", pusher.appId); + MXLogDebug(@"[PushNotificationService][Push] removePusher: %@", pusher.appId); // Shortcut MatrixKit and its complex logic and call directly the API [session.matrixRestClient setPusherWithPushkey:pusher.pushkey @@ -281,14 +281,14 @@ Matrix session observer used to detect new opened sessions. data:pusher.data.JSONDictionary append:NO success:^{ - NSLog(@"[PushNotificationService][Push] removePusher: Success"); + MXLogDebug(@"[PushNotificationService][Push] removePusher: Success"); // Brute clean remaining MatrixKit data [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"pushDeviceToken"]; [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"pushOptions"]; } failure:^(NSError *error) { - NSLog(@"[PushNotificationService][Push] removePusher: Error: %@", error); + MXLogDebug(@"[PushNotificationService][Push] removePusher: Error: %@", error); }]; } @@ -299,14 +299,14 @@ Matrix session observer used to detect new opened sessions. NSArray *mxAccounts = [MXKAccountManager sharedManager].activeAccounts; for (MXKAccount *account in mxAccounts) { - NSLog(@"[PushNotificationService] launchBackgroundSync"); + MXLogDebug(@"[PushNotificationService] launchBackgroundSync"); [account backgroundSync:20000 success:^{ [[UNUserNotificationCenter currentNotificationCenter] removeUnwantedNotifications]; [[UNUserNotificationCenter currentNotificationCenter] removeCallNotificationsFor:nil]; - NSLog(@"[PushNotificationService] launchBackgroundSync: the background sync succeeds"); + MXLogDebug(@"[PushNotificationService] launchBackgroundSync: the background sync succeeds"); } failure:^(NSError *error) { - NSLog(@"[PushNotificationService] launchBackgroundSync: the background sync failed. Error: %@ (%@).", error.domain, @(error.code)); + MXLogDebug(@"[PushNotificationService] launchBackgroundSync: the background sync failed. Error: %@ (%@).", error.domain, @(error.code)); }]; } } @@ -367,14 +367,14 @@ Matrix session observer used to detect new opened sessions. trigger:nil]; [center addNotificationRequest:failureNotificationRequest withCompletionHandler:nil]; - NSLog(@"[PushNotificationService][Push] didReceiveNotificationResponse: error sending text message: %@", error); + MXLogDebug(@"[PushNotificationService][Push] didReceiveNotificationResponse: error sending text message: %@", error); completionHandler(); }]; } else { - NSLog(@"[PushNotificationService][Push] didReceiveNotificationResponse: error, expect a response of type UNTextInputNotificationResponse"); + MXLogDebug(@"[PushNotificationService][Push] didReceiveNotificationResponse: error, expect a response of type UNTextInputNotificationResponse"); completionHandler(); } } @@ -385,7 +385,7 @@ Matrix session observer used to detect new opened sessions. } else { - NSLog(@"[PushNotificationService][Push] didReceiveNotificationResponse: unhandled identifier %@", actionIdentifier); + MXLogDebug(@"[PushNotificationService][Push] didReceiveNotificationResponse: unhandled identifier %@", actionIdentifier); completionHandler(); } } @@ -452,7 +452,7 @@ Matrix session observer used to detect new opened sessions. dispatch_group_notify(group, dispatch_get_main_queue(), ^{ if (manager == nil) { - NSLog(@"[PushNotificationService][Push] didReceiveNotificationResponse: room with id %@ not found", roomId); + MXLogDebug(@"[PushNotificationService][Push] didReceiveNotificationResponse: room with id %@ not found", roomId); failure(nil); } else @@ -460,7 +460,7 @@ Matrix session observer used to detect new opened sessions. [manager roomDataSourceForRoom:roomId create:YES onComplete:^(MXKRoomDataSource *roomDataSource) { if (responseText != nil && responseText.length != 0) { - NSLog(@"[PushNotificationService][Push] didReceiveNotificationResponse: sending message to room: %@", roomId); + MXLogDebug(@"[PushNotificationService][Push] didReceiveNotificationResponse: sending message to room: %@", roomId); [roomDataSource sendTextMessage:responseText success:^(NSString* eventId) { success(eventId); } failure:^(NSError* error) { @@ -478,7 +478,7 @@ Matrix session observer used to detect new opened sessions. - (void)clearPushNotificationToken { - NSLog(@"[PushNotificationService][Push] clearPushNotificationToken: Clear existing token"); + MXLogDebug(@"[PushNotificationService][Push] clearPushNotificationToken: Clear existing token"); // Clear existing pushkit token registered on the HS MXKAccountManager* accountManager = [MXKAccountManager sharedManager]; @@ -488,7 +488,7 @@ Matrix session observer used to detect new opened sessions. // Remove delivred notifications for a given room id except call notifications - (void)removeDeliveredNotificationsWithRoomId:(NSString*)roomId completion:(dispatch_block_t)completion { - NSLog(@"[PushNotificationService][Push] removeDeliveredNotificationsWithRoomId: Remove potential delivered notifications for room id: %@", roomId); + MXLogDebug(@"[PushNotificationService][Push] removeDeliveredNotificationsWithRoomId: Remove potential delivered notifications for room id: %@", roomId); NSMutableArray *notificationRequestIdentifiersToRemove = [NSMutableArray new]; @@ -529,7 +529,7 @@ Matrix session observer used to detect new opened sessions. - (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)pushCredentials forType:(PKPushType)type { - NSLog(@"[PushNotificationService] did update PushKit credentials"); + MXLogDebug(@"[PushNotificationService] did update PushKit credentials"); _pushNotificationStore.pushKitToken = pushCredentials.token; if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) { @@ -539,7 +539,7 @@ Matrix session observer used to detect new opened sessions. - (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void (^)(void))completion { - NSLog(@"[PushNotificationService] didReceiveIncomingPushWithPayload: %@", payload.dictionaryPayload); + MXLogDebug(@"[PushNotificationService] didReceiveIncomingPushWithPayload: %@", payload.dictionaryPayload); NSString *roomId = payload.dictionaryPayload[@"room_id"]; NSString *eventId = payload.dictionaryPayload[@"event_id"]; @@ -549,7 +549,7 @@ Matrix session observer used to detect new opened sessions. if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) { - NSLog(@"[PushNotificationService] didReceiveIncomingPushWithPayload: application is in bg"); + MXLogDebug(@"[PushNotificationService] didReceiveIncomingPushWithPayload: application is in bg"); if (@available(iOS 13.0, *)) { @@ -561,7 +561,7 @@ Matrix session observer used to detect new opened sessions. // when we have a VoIP push while the application is killed, session.callManager will not be ready yet. Configure it. [[AppDelegate theDelegate] configureCallManagerIfRequiredForSession:session]; - NSLog(@"[PushNotificationService] didReceiveIncomingPushWithPayload: callInvite: %@", callInvite); + MXLogDebug(@"[PushNotificationService] didReceiveIncomingPushWithPayload: callInvite: %@", callInvite); if (callInvite) { @@ -584,7 +584,7 @@ Matrix session observer used to detect new opened sessions. if (call) { [session.callManager.callKitAdapter reportIncomingCall:call]; - NSLog(@"[PushNotificationService] didReceiveIncomingPushWithPayload: Reporting new call in room %@ for the event: %@", roomId, eventId); + MXLogDebug(@"[PushNotificationService] didReceiveIncomingPushWithPayload: Reporting new call in room %@ for the event: %@", roomId, eventId); // Wait for the sync response in cache to be processed for data integrity. dispatch_group_notify(dispatchGroup, dispatch_get_main_queue(), ^{ @@ -594,7 +594,7 @@ Matrix session observer used to detect new opened sessions. } else { - NSLog(@"[PushNotificationService] didReceiveIncomingPushWithPayload: Error on call object on room %@ for the event: %@", roomId, eventId); + MXLogDebug(@"[PushNotificationService] didReceiveIncomingPushWithPayload: Error on call object on room %@ for the event: %@", roomId, eventId); } } else if ([callInvite.type isEqualToString:kWidgetMatrixEventTypeString] || @@ -606,13 +606,13 @@ Matrix session observer used to detect new opened sessions. else { // It's a serious error. There is nothing to avoid iOS to kill us here. - NSLog(@"[PushNotificationService] didReceiveIncomingPushWithPayload: We have an unknown type of event for %@. There is something wrong.", eventId); + MXLogDebug(@"[PushNotificationService] didReceiveIncomingPushWithPayload: We have an unknown type of event for %@. There is something wrong.", eventId); } } else { // It's a serious error. There is nothing to avoid iOS to kill us here. - NSLog(@"[PushNotificationService] didReceiveIncomingPushWithPayload: iOS 13 and in bg, but we don't have the callInvite event for the eventId: %@. There is something wrong.", eventId); + MXLogDebug(@"[PushNotificationService] didReceiveIncomingPushWithPayload: iOS 13 and in bg, but we don't have the callInvite event for the eventId: %@. There is something wrong.", eventId); } } else @@ -623,7 +623,7 @@ Matrix session observer used to detect new opened sessions. } else { - NSLog(@"[PushNotificationService] didReceiveIncomingPushWithPayload: application is not in bg. There is something wrong."); + MXLogDebug(@"[PushNotificationService] didReceiveIncomingPushWithPayload: application is not in bg. There is something wrong."); } completion(); diff --git a/Riot/Managers/PushNotification/PushNotificationStore.swift b/Riot/Managers/PushNotification/PushNotificationStore.swift index ea2ba1852..2c54faf7c 100644 --- a/Riot/Managers/PushNotification/PushNotificationStore.swift +++ b/Riot/Managers/PushNotification/PushNotificationStore.swift @@ -46,14 +46,14 @@ final class PushNotificationStore: NSObject { do { return try store.data(forKey: StoreKeys.pushToken) } catch let error { - NSLog("[PinCodePreferences] Error when reading push token from store: \(error)") + MXLog.debug("[PinCodePreferences] Error when reading push token from store: \(error)") return nil } } set { do { try store.set(newValue, forKey: StoreKeys.pushToken) } catch let error { - NSLog("[PinCodePreferences] Error when storing push token to the store: \(error)") + MXLog.debug("[PinCodePreferences] Error when storing push token to the store: \(error)") } } } diff --git a/Riot/Managers/UserSessions/UserSessionsService.swift b/Riot/Managers/UserSessions/UserSessionsService.swift index d53bb79de..cd79fbd92 100644 --- a/Riot/Managers/UserSessions/UserSessionsService.swift +++ b/Riot/Managers/UserSessions/UserSessionsService.swift @@ -97,7 +97,7 @@ class UserSessionsService: NSObject { let userSession = UserSession(account: account, matrixSession: matrixSession) self.userSessions.append(userSession) - NSLog("[UserSessionsService] addUserSession from account with user id: \(userSession.userId)") + MXLog.debug("[UserSessionsService] addUserSession from account with user id: \(userSession.userId)") if postNotification { NotificationCenter.default.post(name: UserSessionsService.didAddUserSession, object: self, userInfo: [NotificationUserInfoKey.userSession: userSession]) @@ -119,7 +119,7 @@ class UserSessionsService: NSObject { return userId == userSession.userId } - NSLog("[UserSessionsService] removeUserSession related to account with user id: \(userId)") + MXLog.debug("[UserSessionsService] removeUserSession related to account with user id: \(userId)") if postNotification { NotificationCenter.default.post(name: UserSessionsService.didRemoveUserSession, object: self, userInfo: [NotificationUserInfoKey.userId: userId]) @@ -132,7 +132,7 @@ class UserSessionsService: NSObject { } guard let mxSession = account.mxSession else { - NSLog("[UserSessionsService] Cannot add a UserSession from a MXKAccount with nil Matrix session") + MXLog.debug("[UserSessionsService] Cannot add a UserSession from a MXKAccount with nil Matrix session") return false } diff --git a/Riot/Managers/Widgets/Widget.m b/Riot/Managers/Widgets/Widget.m index 29eba78ab..ad1acbd77 100644 --- a/Riot/Managers/Widgets/Widget.m +++ b/Riot/Managers/Widgets/Widget.m @@ -101,7 +101,7 @@ } else { - NSLog(@"[Widget] Error: Invalid data field value in %@ for key %@ in data %@", self, key, _data); + MXLogDebug(@"[Widget] Error: Invalid data field value in %@ for key %@ in data %@", self, key, _data); } } diff --git a/Riot/Managers/Widgets/WidgetManager.m b/Riot/Managers/Widgets/WidgetManager.m index ac212da1a..f336cbade 100644 --- a/Riot/Managers/Widgets/WidgetManager.m +++ b/Riot/Managers/Widgets/WidgetManager.m @@ -185,7 +185,7 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain"; { if (![widgetEventContent isKindOfClass:NSDictionary.class]) { - NSLog(@"[WidgetManager] userWidgets: ERROR: invalid user widget format: %@", widgetEventContent); + MXLogDebug(@"[WidgetManager] userWidgets: ERROR: invalid user widget format: %@", widgetEventContent); continue; } @@ -262,7 +262,7 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain"; WidgetManagerConfig *config = [self configForUser:userId]; if (!config.hasUrls) { - NSLog(@"[WidgetManager] createJitsiWidgetInRoom: Error: no Integrations Manager API URL for user %@", userId); + MXLogDebug(@"[WidgetManager] createJitsiWidgetInRoom: Error: no Integrations Manager API URL for user %@", userId); failure(self.errorForNonConfiguredIntegrationManager); return nil; } @@ -270,7 +270,7 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain"; RiotSharedSettings *sharedSettings = [[RiotSharedSettings alloc] initWithSession:room.mxSession]; if (!sharedSettings.hasIntegrationProvisioningEnabled) { - NSLog(@"[WidgetManager] createJitsiWidgetInRoom: Error: Disabled integration manager for user %@", userId); + MXLogDebug(@"[WidgetManager] createJitsiWidgetInRoom: Error: Disabled integration manager for user %@", userId); failure(self.errorForDisabledIntegrationManager); return nil; } @@ -391,11 +391,11 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain"; NSString *widgetId = event.stateKey; if (!widgetId) { - NSLog(@"[WidgetManager] Error: New widget detected with no id in %@: %@", event.roomId, event.JSONDictionary); + MXLogDebug(@"[WidgetManager] Error: New widget detected with no id in %@: %@", event.roomId, event.JSONDictionary); return; } - NSLog(@"[WidgetManager] New widget detected: %@ in %@", widgetId, event.roomId); + MXLogDebug(@"[WidgetManager] New widget detected: %@ in %@", widgetId, event.roomId); Widget *widget = [[Widget alloc] initWithWidgetEvent:event inMatrixSession:mxSession]; if (widget) @@ -411,7 +411,7 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain"; } else { - NSLog(@"[WidgetManager] Cannot decode new widget - event: %@", event); + MXLogDebug(@"[WidgetManager] Cannot decode new widget - event: %@", event); if (self->failureBlockForWidgetCreation[hash][widgetId]) { @@ -545,7 +545,7 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain"; } else { - NSLog(@"[WidgetManager] getScalarTokenForMXSession: Invalid stored token. Need to register for a new token"); + MXLogDebug(@"[WidgetManager] getScalarTokenForMXSession: Invalid stored token. Need to register for a new token"); MXHTTPOperation *operation2 = [self registerForScalarToken:mxSession success:success failure:failure]; [operation mutateTo:operation2]; } @@ -555,7 +555,7 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain"; } else { - NSLog(@"[WidgetManager] getScalarTokenForMXSession: Need to register for a token"); + MXLogDebug(@"[WidgetManager] getScalarTokenForMXSession: Need to register for a token"); operation = [self registerForScalarToken:mxSession success:success failure:failure]; } @@ -569,12 +569,12 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain"; MXHTTPOperation *operation; NSString *userId = mxSession.myUser.userId; - NSLog(@"[WidgetManager] registerForScalarToken"); + MXLogDebug(@"[WidgetManager] registerForScalarToken"); WidgetManagerConfig *config = [self configForUser:userId]; if (!config.hasUrls) { - NSLog(@"[WidgetManager] registerForScalarToken: Error: no Integrations Manager API URL for user %@", mxSession.myUser.userId); + MXLogDebug(@"[WidgetManager] registerForScalarToken: Error: no Integrations Manager API URL for user %@", mxSession.myUser.userId); failure(self.errorForNonConfiguredIntegrationManager); return nil; } @@ -616,7 +616,7 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain"; } failure:^(NSError *error) { httpClient = nil; - NSLog(@"[WidgetManager] registerForScalarToken: Failed to register. Error: %@", error); + MXLogDebug(@"[WidgetManager] registerForScalarToken: Failed to register. Error: %@", error); if (failure) { @@ -634,7 +634,7 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain"; [operation mutateTo:operation2]; } failure:^(NSError *error) { - NSLog(@"[WidgetManager] registerForScalarToken. Error in openIdToken request"); + MXLogDebug(@"[WidgetManager] registerForScalarToken. Error in openIdToken request"); if (failure) { @@ -654,7 +654,7 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain"; WidgetManagerConfig *config = [self configForUser:userId]; if (!config.hasUrls) { - NSLog(@"[WidgetManager] validateScalarToken: Error: no Integrations Manager API URL for user %@", mxSession.myUser.userId); + MXLogDebug(@"[WidgetManager] validateScalarToken: Error: no Integrations Manager API URL for user %@", mxSession.myUser.userId); failure(self.errorForNonConfiguredIntegrationManager); return nil; } @@ -676,7 +676,7 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain"; } else { - NSLog(@"[WidgetManager] validateScalarToken. Unexpected modular/account response: %@", JSONResponse); + MXLogDebug(@"[WidgetManager] validateScalarToken. Unexpected modular/account response: %@", JSONResponse); complete(NO); } @@ -685,12 +685,12 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain"; NSHTTPURLResponse *urlResponse = [MXHTTPOperation urlResponseFromError:error]; - NSLog(@"[WidgetManager] validateScalarToken. Error in modular/account request. statusCode: %@", @(urlResponse.statusCode)); + MXLogDebug(@"[WidgetManager] validateScalarToken. Error in modular/account request. statusCode: %@", @(urlResponse.statusCode)); MXError *mxError = [[MXError alloc] initWithNSError:error]; if ([mxError.errcode isEqualToString:kMXErrCodeStringTermsNotSigned]) { - NSLog(@"[WidgetManager] validateScalarToke. Error: Need to accept terms"); + MXLogDebug(@"[WidgetManager] validateScalarToke. Error: Need to accept terms"); NSError *termsNotSignedError = [NSError errorWithDomain:WidgetManagerErrorDomain code:WidgetManagerErrorCodeTermsNotSigned userInfo:@{ @@ -757,7 +757,7 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain"; { NSString *scalarToken = scalarTokens[userId]; - NSLog(@"[WidgetManager] migrate scalarTokens to integrationManagerConfigs for %@", userId); + MXLogDebug(@"[WidgetManager] migrate scalarTokens to integrationManagerConfigs for %@", userId); WidgetManagerConfig *config = [self createWidgetManagerConfigWithAppSettings]; config.scalarToken = scalarToken; diff --git a/Riot/Model/HomeserverConfiguration/HomeserverConfigurationBuilder.swift b/Riot/Model/HomeserverConfiguration/HomeserverConfigurationBuilder.swift index c77ff6bab..f3cf06e13 100644 --- a/Riot/Model/HomeserverConfiguration/HomeserverConfigurationBuilder.swift +++ b/Riot/Model/HomeserverConfiguration/HomeserverConfigurationBuilder.swift @@ -80,10 +80,10 @@ final class HomeserverConfigurationBuilder: NSObject { if let lastJitsiConfiguration = vectorWellKnown.jitsi { jitsiConfiguration = lastJitsiConfiguration } else if let deprecatedJitsiConfiguration = vectorWellKnown.deprecatedJitsi { - NSLog("[HomeserverConfigurationBuilder] getJitsiConfiguration - Use deprecated configuration") + MXLog.debug("[HomeserverConfigurationBuilder] getJitsiConfiguration - Use deprecated configuration") jitsiConfiguration = deprecatedJitsiConfiguration } else { - NSLog("[HomeserverConfigurationBuilder] getJitsiConfiguration - No configuration found") + MXLog.debug("[HomeserverConfigurationBuilder] getJitsiConfiguration - No configuration found") jitsiConfiguration = nil } @@ -97,10 +97,10 @@ final class HomeserverConfigurationBuilder: NSObject { if let lastEncryptionConfiguration = vectorWellKnown.encryption { encryptionConfiguration = lastEncryptionConfiguration } else if let deprecatedEncryptionConfiguration = vectorWellKnown.deprecatedEncryption { - NSLog("[HomeserverConfigurationBuilder] getEncryptionConfiguration - Use deprecated configuration") + MXLog.debug("[HomeserverConfigurationBuilder] getEncryptionConfiguration - Use deprecated configuration") encryptionConfiguration = deprecatedEncryptionConfiguration } else { - NSLog("[HomeserverConfigurationBuilder] getEncryptionConfiguration - No configuration found") + MXLog.debug("[HomeserverConfigurationBuilder] getEncryptionConfiguration - No configuration found") encryptionConfiguration = nil } @@ -116,7 +116,7 @@ final class HomeserverConfigurationBuilder: NSObject { } guard let jitsiServerURL = URL(string: jitsiStringURL) else { - NSLog("[HomeserverConfigurationBuilder] Jitsi server URL is not valid") + MXLog.debug("[HomeserverConfigurationBuilder] Jitsi server URL is not valid") return nil } diff --git a/Riot/Model/WellKnown/VectorWellKnownParser.swift b/Riot/Model/WellKnown/VectorWellKnownParser.swift index 3fc7325c6..4a2d420e1 100644 --- a/Riot/Model/WellKnown/VectorWellKnownParser.swift +++ b/Riot/Model/WellKnown/VectorWellKnownParser.swift @@ -26,7 +26,7 @@ final class VectorWellKnownParser { vectorWellKnown = try serializationService.deserialize(jsonDictionary) } catch { vectorWellKnown = nil - NSLog("[VectorWellKnownParser] Fail to parse application Well Known keys with error: \(error)") + MXLog.debug("[VectorWellKnownParser] Fail to parse application Well Known keys with error: \(error)") } return vectorWellKnown diff --git a/Riot/Modules/Application/AppCoordinator.swift b/Riot/Modules/Application/AppCoordinator.swift index bb0787e16..3b69cc6e5 100755 --- a/Riot/Modules/Application/AppCoordinator.swift +++ b/Riot/Modules/Application/AppCoordinator.swift @@ -60,7 +60,7 @@ final class AppCoordinator: NSObject, AppCoordinatorType { func start() { // NOTE: When split view is shown there can be no Matrix sessions ready. Keep this behavior or use a loading screen before showing the spit view. self.showSplitView() - NSLog("[AppCoordinator] Showed split view") + MXLog.debug("[AppCoordinator] Showed split view") } func open(url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool { @@ -70,7 +70,7 @@ final class AppCoordinator: NSObject, AppCoordinatorType { let deepLinkOption = try self.customSchemeURLParser.parse(url: url, options: options) return self.handleDeepLinkOption(deepLinkOption) } catch { - NSLog("[AppCoordinator] Custom scheme URL parsing failed with error: \(error)") + MXLog.debug("[AppCoordinator] Custom scheme URL parsing failed with error: \(error)") return false } } @@ -126,7 +126,7 @@ extension AppCoordinator: LegacyAppDelegateDelegate { func legacyAppDelegate(_ legacyAppDelegate: LegacyAppDelegate!, wantsToPopToHomeViewControllerAnimated animated: Bool, completion: (() -> Void)!) { - NSLog("[AppCoordinator] wantsToPopToHomeViewControllerAnimated") + MXLog.debug("[AppCoordinator] wantsToPopToHomeViewControllerAnimated") self.splitViewCoordinator?.popToHome(animated: animated, completion: completion) } diff --git a/Riot/Modules/Application/LegacyAppDelegate.m b/Riot/Modules/Application/LegacyAppDelegate.m index 56a866c8b..9158de0df 100644 --- a/Riot/Modules/Application/LegacyAppDelegate.m +++ b/Riot/Modules/Application/LegacyAppDelegate.m @@ -238,19 +238,24 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni + (void)initialize { - NSLog(@"[AppDelegate] initialize"); - + MXLogDebug(@"[AppDelegate] initialize"); + // Set static application settings [[AppConfiguration new] setupSettings]; - + + MXLogConfiguration *configuration = [[MXLogConfiguration alloc] init]; + configuration.logLevel = MXLogLevelVerbose; + configuration.logFilesSizeLimit = 100 * 1024 * 1024; // 100MB + configuration.maxLogFilesCount = 50; + // Redirect NSLogs to files only if we are not debugging - if (!isatty(STDERR_FILENO)) - { - NSUInteger sizeLimit = 100 * 1024 * 1024; // 100MB - [MXLogger redirectNSLogToFiles:YES numberOfFiles:50 sizeLimit:sizeLimit]; + if (!isatty(STDERR_FILENO)) { + configuration.redirectLogsToFiles = YES; } + + [MXLog configure:configuration]; - NSLog(@"[AppDelegate] initialize: Done"); + MXLogDebug(@"[AppDelegate] initialize: Done"); } + (instancetype)theDelegate @@ -282,7 +287,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni stringByReplacingOccurrencesOfString: @">" withString: @""] stringByReplacingOccurrencesOfString: @" " withString: @""]; - NSLog(@"The generated device token string is : %@",deviceTokenString); + MXLogDebug(@"The generated device token string is : %@",deviceTokenString); } - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error @@ -373,7 +378,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni NSURL *messageSoundURL = [[NSBundle mainBundle] URLForResource:@"message" withExtension:@"caf"]; AudioServicesCreateSystemSoundID((__bridge CFURLRef)messageSoundURL, &_messageSound); - NSLog(@"[AppDelegate] willFinishLaunchingWithOptions: Done"); + MXLogDebug(@"[AppDelegate] willFinishLaunchingWithOptions: Done"); return YES; } @@ -384,16 +389,16 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni #ifdef DEBUG // log the full launchOptions only in DEBUG - NSLog(@"[AppDelegate] didFinishLaunchingWithOptions: %@", launchOptions); + MXLogDebug(@"[AppDelegate] didFinishLaunchingWithOptions: %@", launchOptions); #else - NSLog(@"[AppDelegate] didFinishLaunchingWithOptions"); + MXLogDebug(@"[AppDelegate] didFinishLaunchingWithOptions"); #endif - NSLog(@"[AppDelegate] didFinishLaunchingWithOptions: isProtectedDataAvailable: %@", @([application isProtectedDataAvailable])); + MXLogDebug(@"[AppDelegate] didFinishLaunchingWithOptions: isProtectedDataAvailable: %@", @([application isProtectedDataAvailable])); if (![application isProtectedDataAvailable]) { - NSLog(@"[AppDelegate] didFinishLaunchingWithOptions: Terminating the app because protected data not available"); + MXLogDebug(@"[AppDelegate] didFinishLaunchingWithOptions: Terminating the app because protected data not available"); exit(0); } @@ -404,13 +409,13 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni NSString* appVersion = [AppDelegate theDelegate].appVersion; NSString* build = [AppDelegate theDelegate].build; - NSLog(@"------------------------------"); - NSLog(@"Application info:"); - NSLog(@"%@ version: %@", appDisplayName, appVersion); - NSLog(@"MatrixKit version: %@", MatrixKitVersion); - NSLog(@"MatrixSDK version: %@", MatrixSDKVersion); - NSLog(@"Build: %@\n", build); - NSLog(@"------------------------------\n"); + MXLogDebug(@"------------------------------"); + MXLogDebug(@"Application info:"); + MXLogDebug(@"%@ version: %@", appDisplayName, appVersion); + MXLogDebug(@"MatrixKit version: %@", MatrixKitVersion); + MXLogDebug(@"MatrixSDK version: %@", MatrixSDKVersion); + MXLogDebug(@"Build: %@\n", build); + MXLogDebug(@"------------------------------\n"); [self setupUserDefaults]; @@ -484,7 +489,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni self.majorUpdateManager = [MajorUpdateManager new]; - NSLog(@"[AppDelegate] didFinishLaunchingWithOptions: Done in %.0fms", [[NSDate date] timeIntervalSinceDate:startDate] * 1000); + MXLogDebug(@"[AppDelegate] didFinishLaunchingWithOptions: Done in %.0fms", [[NSDate date] timeIntervalSinceDate:startDate] * 1000); dispatch_async(dispatch_get_main_queue(), ^{ [self configurePinCodeScreenFor:application createIfRequired:YES]; @@ -495,7 +500,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni - (void)applicationWillResignActive:(UIApplication *)application { - NSLog(@"[AppDelegate] applicationWillResignActive"); + MXLogDebug(@"[AppDelegate] applicationWillResignActive"); // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. @@ -555,7 +560,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni - (void)applicationDidEnterBackground:(UIApplication *)application { - NSLog(@"[AppDelegate] applicationDidEnterBackground"); + MXLogDebug(@"[AppDelegate] applicationDidEnterBackground"); // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. @@ -606,7 +611,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni - (void)applicationWillEnterForeground:(UIApplication *)application { - NSLog(@"[AppDelegate] applicationWillEnterForeground"); + MXLogDebug(@"[AppDelegate] applicationWillEnterForeground"); // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. @@ -624,7 +629,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni - (void)applicationDidBecomeActive:(UIApplication *)application { - NSLog(@"[AppDelegate] applicationDidBecomeActive"); + MXLogDebug(@"[AppDelegate] applicationDidBecomeActive"); [self.pushNotificationService applicationDidBecomeActive]; @@ -659,7 +664,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni - (void)afterAppUnlockedByPin:(UIApplication *)application { - NSLog(@"[AppDelegate] afterAppUnlockedByPin"); + MXLogDebug(@"[AppDelegate] afterAppUnlockedByPin"); // Check if there is crash log to send if (RiotSettings.shared.enableCrashReport) @@ -745,13 +750,13 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni - (void)applicationWillTerminate:(UIApplication *)application { - NSLog(@"[AppDelegate] applicationWillTerminate"); + MXLogDebug(@"[AppDelegate] applicationWillTerminate"); // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } - (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { - NSLog(@"[AppDelegate] applicationDidReceiveMemoryWarning"); + MXLogDebug(@"[AppDelegate] applicationDidReceiveMemoryWarning"); } - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray> * _Nullable))restorationHandler @@ -858,17 +863,17 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni if (noCallSupportAlert) { - NSLog(@"[AppDelegate] restoreInitialDisplay: keep visible noCall support alert"); + MXLogDebug(@"[AppDelegate] restoreInitialDisplay: keep visible noCall support alert"); [self showNotificationAlert:noCallSupportAlert]; } else if (cryptoDataCorruptedAlert) { - NSLog(@"[AppDelegate] restoreInitialDisplay: keep visible log in again"); + MXLogDebug(@"[AppDelegate] restoreInitialDisplay: keep visible log in again"); [self showNotificationAlert:cryptoDataCorruptedAlert]; } else if (wrongBackupVersionAlert) { - NSLog(@"[AppDelegate] restoreInitialDisplay: keep visible wrongBackupVersionAlert"); + MXLogDebug(@"[AppDelegate] restoreInitialDisplay: keep visible wrongBackupVersionAlert"); [self showNotificationAlert:wrongBackupVersionAlert]; } @@ -1099,7 +1104,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni usedEncoding:nil error:nil]; - NSLog(@"[AppDelegate] Promt user to report crash:\n%@", description); + MXLogDebug(@"[AppDelegate] Promt user to report crash:\n%@", description); // Ask the user to send a crash report [[RageShakeManager sharedManager] promptCrashReportInViewController:self.window.rootViewController]; @@ -1121,7 +1126,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni // Consider the total number of missed discussions including the invites. NSUInteger count = [self.masterTabBarController missedDiscussionsCount]; - NSLog(@"[AppDelegate] refreshApplicationIconBadgeNumber: %tu", count); + MXLogDebug(@"[AppDelegate] refreshApplicationIconBadgeNumber: %tu", count); [UIApplication sharedApplication].applicationIconBadgeNumber = count; } @@ -1131,7 +1136,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni - (BOOL)handleUniversalLink:(NSUserActivity*)userActivity { NSURL *webURL = userActivity.webpageURL; - NSLog(@"[AppDelegate] handleUniversalLink: %@", webURL.absoluteString); + MXLogDebug(@"[AppDelegate] handleUniversalLink: %@", webURL.absoluteString); // iOS Patch: fix vector.im urls before using it webURL = [Tools fixURLWithSeveralHashKeys:webURL]; @@ -1164,7 +1169,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni // They look like https://matrix.org/_matrix/client/unstable/registration/email/submit_token?token=vtQjQIZfwdoREDACTEDozrmKYSWlCXsJ&client_secret=53e679ea-oRED-ACTED-92b8-3012c49c6cfa&sid=qlBCREDACTEDEtgxD if ([webURL.path hasSuffix:@"/email/submit_token"]) { - NSLog(@"[AppDelegate] handleUniversalLink: Validate link"); + MXLogDebug(@"[AppDelegate] handleUniversalLink: Validate link"); // We just need to ping the link. // The app should be in the registration flow at the "waiting for email validation" polling state. The server @@ -1174,12 +1179,12 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni NSURLSessionDataTask * task = [urlSession dataTaskWithURL:webURL completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { - NSLog(@"[AppDelegate] handleUniversalLink: Link validation response: %@\nData: %@", response, + MXLogDebug(@"[AppDelegate] handleUniversalLink: Link validation response: %@\nData: %@", response, [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); if (error) { - NSLog(@"[AppDelegate] handleUniversalLink: Link validation error: %@", error); + MXLogDebug(@"[AppDelegate] handleUniversalLink: Link validation error: %@", error); [self showErrorAsAlert:error]; } }]; @@ -1215,12 +1220,12 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni [identityService submit3PIDValidationToken:queryParams[@"token"] medium:kMX3PIDMediumEmail clientSecret:clientSecret sid:sid success:^{ - NSLog(@"[AppDelegate] handleUniversalLink. Email successfully validated."); + MXLogDebug(@"[AppDelegate] handleUniversalLink. Email successfully validated."); if (queryParams[@"nextLink"]) { // Continue the registration with the passed nextLink - NSLog(@"[AppDelegate] handleUniversalLink. Complete registration with nextLink"); + MXLogDebug(@"[AppDelegate] handleUniversalLink. Complete registration with nextLink"); NSURL *nextLink = [NSURL URLWithString:queryParams[@"nextLink"]]; [self handleUniversalLinkFragment:nextLink.fragment fromURL:nextLink]; } @@ -1240,7 +1245,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni } failure:^(NSError *error) { - NSLog(@"[AppDelegate] handleUniversalLink. Error: submitToken failed"); + MXLogDebug(@"[AppDelegate] handleUniversalLink. Error: submitToken failed"); [self showErrorAsAlert:error]; }]; @@ -1261,11 +1266,11 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni BOOL continueUserActivity = NO; MXKAccountManager *accountManager = [MXKAccountManager sharedManager]; - NSLog(@"[AppDelegate] Universal link: handleUniversalLinkFragment: %@", fragment); + MXLogDebug(@"[AppDelegate] Universal link: handleUniversalLinkFragment: %@", fragment); // Make sure we have plain utf8 character for separators fragment = [fragment stringByRemovingPercentEncoding]; - NSLog(@"[AppDelegate] Universal link: handleUniversalLinkFragment: %@", fragment); + MXLogDebug(@"[AppDelegate] Universal link: handleUniversalLinkFragment: %@", fragment); // The app manages only one universal link at a time // Discard any pending one @@ -1279,7 +1284,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni // Sanity check if (!pathParams.count) { - NSLog(@"[AppDelegate] Universal link: Error: No path parameters"); + MXLogDebug(@"[AppDelegate] Universal link: Error: No path parameters"); return NO; } @@ -1420,12 +1425,12 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni else { // Do not continue. Else we will loop forever - NSLog(@"[AppDelegate] Universal link: Error: Cannot resolve alias in %@ to the room id %@", fragment, roomId); + MXLogDebug(@"[AppDelegate] Universal link: Error: Cannot resolve alias in %@ to the room id %@", fragment, roomId); } } } failure:^(NSError *error) { - NSLog(@"[AppDelegate] Universal link: Error: The homeserver failed to resolve the room alias (%@)", roomIdOrAlias); + MXLogDebug(@"[AppDelegate] Universal link: Error: The homeserver failed to resolve the room alias (%@)", roomIdOrAlias); [homeViewController stopActivityIndicator]; @@ -1441,7 +1446,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni // FIXME: Manange all user's accounts not only the first one MXKAccount* account = accountManager.activeAccounts.firstObject; - NSLog(@"[AppDelegate] Universal link: Need to wait for the session to be sync'ed and running"); + MXLogDebug(@"[AppDelegate] Universal link: Need to wait for the session to be sync'ed and running"); universalLinkFragmentPending = fragment; universalLinkWaitingObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXSessionStateDidChangeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull notif) { @@ -1452,7 +1457,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni // Check whether the concerned session is the associated one if (notif.object == account.mxSession && account.mxSession.state == MXSessionStateRunning) { - NSLog(@"[AppDelegate] Universal link: The session is running. Retry the link"); + MXLogDebug(@"[AppDelegate] Universal link: The session is running. Retry the link"); [self handleUniversalLinkFragment:fragment fromURL:universalLinkURL]; } } @@ -1460,7 +1465,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni } else { - NSLog(@"[AppDelegate] Universal link: The room (%@) is not known by any account (email invitation: %@). Display its preview to try to join it", roomIdOrAlias, queryParams ? @"YES" : @"NO"); + MXLogDebug(@"[AppDelegate] Universal link: The room (%@) is not known by any account (email invitation: %@). Display its preview to try to join it", roomIdOrAlias, queryParams ? @"YES" : @"NO"); // FIXME: In case of multi-account, ask the user which one to use MXKAccount* account = accountManager.activeAccounts.firstObject; @@ -1504,7 +1509,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni { // There is no account. The app will display the AuthenticationVC. // Wait for a successful login - NSLog(@"[AppDelegate] Universal link: The user is not logged in. Wait for a successful login"); + MXLogDebug(@"[AppDelegate] Universal link: The user is not logged in. Wait for a successful login"); universalLinkFragmentPending = fragment; // Register an observer in order to handle new account @@ -1513,7 +1518,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni // Check that 'fragment' has not been cancelled if ([universalLinkFragmentPending isEqualToString:fragment]) { - NSLog(@"[AppDelegate] Universal link: The user is now logged in. Retry the link"); + MXLogDebug(@"[AppDelegate] Universal link: The user is now logged in. Retry the link"); [self handleUniversalLinkFragment:fragment fromURL:universalLinkURL]; } }]; @@ -1569,7 +1574,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni { // There is no account. The app will display the AuthenticationVC. // Wait for a successful login - NSLog(@"[AppDelegate] Universal link: The user is not logged in. Wait for a successful login"); + MXLogDebug(@"[AppDelegate] Universal link: The user is not logged in. Wait for a successful login"); universalLinkFragmentPending = fragment; // Register an observer in order to handle new account @@ -1578,7 +1583,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni // Check that 'fragment' has not been cancelled if ([universalLinkFragmentPending isEqualToString:fragment]) { - NSLog(@"[AppDelegate] Universal link: The user is now logged in. Retry the link"); + MXLogDebug(@"[AppDelegate] Universal link: The user is now logged in. Retry the link"); [self handleUniversalLinkFragment:fragment fromURL:universalLinkURL]; } }]; @@ -1587,7 +1592,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni // Check whether this is a registration links. else if ([pathParams[0] isEqualToString:@"register"]) { - NSLog(@"[AppDelegate] Universal link with registration parameters"); + MXLogDebug(@"[AppDelegate] Universal link with registration parameters"); continueUserActivity = YES; [_masterTabBarController showAuthenticationScreenWithRegistrationParameters:queryParams]; @@ -1595,7 +1600,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni else { // Unknown command: Do nothing except coming back to the main screen - NSLog(@"[AppDelegate] Universal link: TODO: Do not know what to do with the link arguments: %@", pathParams); + MXLogDebug(@"[AppDelegate] Universal link: TODO: Do not know what to do with the link arguments: %@", pathParams); [self popToHomeViewControllerAnimated:NO completion:nil]; } @@ -1698,7 +1703,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni - (BOOL)handleServerProvionningLink:(NSURL*)link { - NSLog(@"[AppDelegate] handleServerProvionningLink: %@", link); + MXLogDebug(@"[AppDelegate] handleServerProvionningLink: %@", link); NSString *homeserver, *identityServer; [self parseServerProvionningLink:link homeserver:&homeserver identityServer:&identityServer]; @@ -1709,7 +1714,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni { [self displayServerProvionningLinkBuyAlreadyLoggedInAlertWithCompletion:^(BOOL logout) { - NSLog(@"[AppDelegate] handleServerProvionningLink: logoutWithConfirmation: logout: %@", @(logout)); + MXLogDebug(@"[AppDelegate] handleServerProvionningLink: logoutWithConfirmation: logout: %@", @(logout)); if (logout) { [self logoutWithConfirmation:NO completion:^(BOOL isLoggedOut) { @@ -1750,11 +1755,11 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni } else { - NSLog(@"[AppDelegate] parseServerProvionningLink: Error: Unknown path: %@", link.path); + MXLogDebug(@"[AppDelegate] parseServerProvionningLink: Error: Unknown path: %@", link.path); } - NSLog(@"[AppDelegate] parseServerProvionningLink: homeserver: %@ - identityServer: %@", *homeserver, *identityServer); + MXLogDebug(@"[AppDelegate] parseServerProvionningLink: homeserver: %@ - identityServer: %@", *homeserver, *identityServer); } - (void)displayServerProvionningLinkBuyAlreadyLoggedInAlertWithCompletion:(void (^)(BOOL logout))completion @@ -1787,7 +1792,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni // TODO: Move this method content in UserSessionsService - (void)initMatrixSessions { - NSLog(@"[AppDelegate] initMatrixSessions"); + MXLogDebug(@"[AppDelegate] initMatrixSessions"); // Set first RoomDataSource class used in Vector [MXKRoomDataSourceManager registerRoomDataSourceClass:RoomDataSource.class]; @@ -1862,7 +1867,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni BOOL isPushRegistered = self.pushNotificationService.isPushRegistered; - NSLog(@"[AppDelegate][Push] didAddAccountNotification: isPushRegistered: %@", @(isPushRegistered)); + MXLogDebug(@"[AppDelegate][Push] didAddAccountNotification: isPushRegistered: %@", @(isPushRegistered)); if (isPushRegistered) { @@ -1926,7 +1931,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni [[NSNotificationCenter defaultCenter] addObserverForName:kMXSessionIgnoredUsersDidChangeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull notif) { - NSLog(@"[AppDelegate] kMXSessionIgnoredUsersDidChangeNotification received. Reload the app"); + MXLogDebug(@"[AppDelegate] kMXSessionIgnoredUsersDidChangeNotification received. Reload the app"); // Reload entirely the app when a user has been ignored or unignored [[AppDelegate theDelegate] reloadMatrixSessions:YES]; @@ -1935,7 +1940,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni [[NSNotificationCenter defaultCenter] addObserverForName:kMXSessionDidCorruptDataNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull notif) { - NSLog(@"[AppDelegate] kMXSessionDidCorruptDataNotification received. Reload the app"); + MXLogDebug(@"[AppDelegate] kMXSessionDidCorruptDataNotification received. Reload the app"); // Reload entirely the app when a session has corrupted its data [[AppDelegate theDelegate] reloadMatrixSessions:YES]; @@ -1952,7 +1957,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni accountManager.storeClass = [MXFileStore class]; // Observers have been defined, we can start a matrix session for each enabled accounts. - NSLog(@"[AppDelegate] initMatrixSessions: prepareSessionForActiveAccounts (app state: %tu)", [[UIApplication sharedApplication] applicationState]); + MXLogDebug(@"[AppDelegate] initMatrixSessions: prepareSessionForActiveAccounts (app state: %tu)", [[UIApplication sharedApplication] applicationState]); [accountManager prepareSessionForActiveAccounts]; // Check whether we're already logged in @@ -2261,7 +2266,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni if (_masterTabBarController.authenticationInProgress) { - NSLog(@"[AppDelegate] handleAppState: Authentication still in progress"); + MXLogDebug(@"[AppDelegate] handleAppState: Authentication still in progress"); // Wait for the return of masterTabBarControllerDidCompleteAuthentication isLaunching = YES; @@ -2290,11 +2295,11 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni } } - NSLog(@"[AppDelegate] handleAppState: isLaunching: %@", isLaunching ? @"YES" : @"NO"); + MXLogDebug(@"[AppDelegate] handleAppState: isLaunching: %@", isLaunching ? @"YES" : @"NO"); if (isLaunching) { - NSLog(@"[AppDelegate] handleAppState: LaunchLoadingView"); + MXLogDebug(@"[AppDelegate] handleAppState: LaunchLoadingView"); [self showLaunchAnimation]; return; } @@ -2303,7 +2308,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni if (self.setPinCoordinatorBridgePresenter) { - NSLog(@"[AppDelegate] handleAppState: PIN code is presented. Do not go further"); + MXLogDebug(@"[AppDelegate] handleAppState: PIN code is presented. Do not go further"); return; } @@ -2314,23 +2319,23 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni [mainSession.crypto.crossSigning refreshStateWithSuccess:^(BOOL stateUpdated) { MXStrongifyAndReturnIfNil(self); - NSLog(@"[AppDelegate] handleAppState: crossSigning.state: %@", @(mainSession.crypto.crossSigning.state)); + MXLogDebug(@"[AppDelegate] handleAppState: crossSigning.state: %@", @(mainSession.crypto.crossSigning.state)); switch (mainSession.crypto.crossSigning.state) { case MXCrossSigningStateCrossSigningExists: - NSLog(@"[AppDelegate] handleAppState: presentVerifyCurrentSessionAlertIfNeededWithSession"); + MXLogDebug(@"[AppDelegate] handleAppState: presentVerifyCurrentSessionAlertIfNeededWithSession"); [self.masterTabBarController presentVerifyCurrentSessionAlertIfNeededWithSession:mainSession]; break; case MXCrossSigningStateCanCrossSign: - NSLog(@"[AppDelegate] handleAppState: presentReviewUnverifiedSessionsAlertIfNeededWithSession"); + MXLogDebug(@"[AppDelegate] handleAppState: presentReviewUnverifiedSessionsAlertIfNeededWithSession"); [self.masterTabBarController presentReviewUnverifiedSessionsAlertIfNeededWithSession:mainSession]; break; default: break; } } failure:^(NSError * _Nonnull error) { - NSLog(@"[AppDelegate] handleAppState: crossSigning.state: %@. Error: %@", @(mainSession.crypto.crossSigning.state), error); + MXLogDebug(@"[AppDelegate] handleAppState: crossSigning.state: %@. Error: %@", @(mainSession.crypto.crossSigning.state), error); }]; } @@ -2338,7 +2343,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni // protect each other. // This is the time to check existing requests - NSLog(@"[AppDelegate] handleAppState: Check pending verification requests"); + MXLogDebug(@"[AppDelegate] handleAppState: Check pending verification requests"); [self checkPendingRoomKeyRequests]; [self checkPendingIncomingKeyVerificationsInSession:mainSession]; @@ -2346,7 +2351,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni // For the moment, reuse an existing boolean to avoid register things several times if (!incomingKeyVerificationObserver) { - NSLog(@"[AppDelegate] handleAppState: Set up observers for the crypto module"); + MXLogDebug(@"[AppDelegate] handleAppState: Set up observers for the crypto module"); // Enable listening of incoming key share requests [self enableRoomKeyRequestObserver:mainSession]; @@ -2363,7 +2368,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni if (!launchAnimationContainerView && window) { - NSLog(@"[AppDelegate] showLaunchAnimation"); + MXLogDebug(@"[AppDelegate] showLaunchAnimation"); LaunchLoadingView *launchLoadingView = [LaunchLoadingView instantiate]; launchLoadingView.frame = window.bounds; @@ -2389,7 +2394,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni { [profiler stopMeasuringTaskWithProfile:launchTaskProfile]; - NSLog(@"[AppDelegate] hideLaunchAnimation: LaunchAnimation was shown for %.3fms", launchTaskProfile.duration * 1000); + MXLogDebug(@"[AppDelegate] hideLaunchAnimation: LaunchAnimation was shown for %.3fms", launchTaskProfile.duration * 1000); } [self->launchAnimationContainerView removeFromSuperview]; @@ -2500,7 +2505,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni || (mxSession.crypto.crossSigning.canTrustCrossSigning && !mxSession.crypto.crossSigning.canCrossSign)) { // We should have 3 of them. If not, request them again as mitigation - NSLog(@"[AppDelegate] checkLocalPrivateKeysInSession: request keys because keysCount = %@", @(keysCount)); + MXLogDebug(@"[AppDelegate] checkLocalPrivateKeysInSession: request keys because keysCount = %@", @(keysCount)); [mxSession.crypto requestAllPrivateKeys]; } } @@ -2527,7 +2532,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni // Check if there is a device id if (!mxSession.matrixRestClient.credentials.deviceId) { - NSLog(@"WARNING: The user has no device. Prompt for login again"); + MXLogDebug(@"WARNING: The user has no device. Prompt for login again"); NSString *msg = NSLocalizedStringFromTable(@"e2e_enabling_on_app_update", @"Vector", nil); @@ -2766,13 +2771,13 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni // sanity checks if (dedicatedAccount && dedicatedAccount.mxSession) { - NSLog(@"[AppDelegate][Push] navigateToRoomById: open the roomViewController %@", roomId); + MXLogDebug(@"[AppDelegate][Push] navigateToRoomById: open the roomViewController %@", roomId); [self showRoom:roomId andEventId:nil withMatrixSession:dedicatedAccount.mxSession]; } else { - NSLog(@"[AppDelegate][Push] navigateToRoomById : no linked session / account has been found."); + MXLogDebug(@"[AppDelegate][Push] navigateToRoomById : no linked session / account has been found."); } } } @@ -2871,7 +2876,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni NSArray *invite = ((userId && ![mxSession.myUser.userId isEqualToString:userId]) ? @[userId] : nil); void (^onFailure)(NSError *) = ^(NSError *error){ - NSLog(@"[AppDelegate] Create direct chat failed"); + MXLogDebug(@"[AppDelegate] Create direct chat failed"); //Alert user [self showErrorAsAlert:error]; @@ -3104,7 +3109,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni } failure:^(NSError * _Nullable error) { - NSLog(@"[WidgetVC] setPermissionForWidget failed. Error: %@", error); + MXLogDebug(@"[WidgetVC] setPermissionForWidget failed. Error: %@", error); sharedSettings = nil; }]; @@ -3393,7 +3398,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni }; [mxSession.matrixRestClient sendEventToRoom:event.roomId eventType:kMXEventTypeStringCallReject content:content txnId:nil success:nil failure:^(NSError *error) { - NSLog(@"[AppDelegate] enableNoVoIPOnMatrixSession: ERROR: Cannot send m.call.reject event."); + MXLogDebug(@"[AppDelegate] enableNoVoIPOnMatrixSession: ERROR: Cannot send m.call.reject event."); }]; if (weakSelf) @@ -3478,7 +3483,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni { if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) { - NSLog(@"[AppDelegate] checkPendingRoomKeyRequestsInSession called while the app is not active. Ignore it."); + MXLogDebug(@"[AppDelegate] checkPendingRoomKeyRequestsInSession called while the app is not active. Ignore it."); return; } @@ -3486,10 +3491,10 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni [mxSession.crypto pendingKeyRequests:^(MXUsersDevicesMap *> *pendingKeyRequests) { MXStrongifyAndReturnIfNil(self); - NSLog(@"[AppDelegate] checkPendingRoomKeyRequestsInSession: cross-signing state: %ld, pendingKeyRequests.count: %@. Already displayed: %@", - mxSession.crypto.crossSigning.state, - @(pendingKeyRequests.count), - self->roomKeyRequestViewController ? @"YES" : @"NO"); + MXLogDebug(@"[AppDelegate] checkPendingRoomKeyRequestsInSession: cross-signing state: %ld, pendingKeyRequests.count: %@. Already displayed: %@", + mxSession.crypto.crossSigning.state, + @(pendingKeyRequests.count), + self->roomKeyRequestViewController ? @"YES" : @"NO"); if (!mxSession.crypto.crossSigning || mxSession.crypto.crossSigning.state == MXCrossSigningStateNotBootstrapped) { @@ -3504,7 +3509,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni if (currentMXSession == mxSession && currentPendingRequest.count == 0) { - NSLog(@"[AppDelegate] checkPendingRoomKeyRequestsInSession: Cancel current dialog"); + MXLogDebug(@"[AppDelegate] checkPendingRoomKeyRequestsInSession: Cancel current dialog"); // The key request has been probably cancelled, remove the popup [self->roomKeyRequestViewController hide]; @@ -3533,7 +3538,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni void (^openDialog)(void) = ^void() { - NSLog(@"[AppDelegate] checkPendingRoomKeyRequestsInSession: Open dialog for %@", deviceInfo); + MXLogDebug(@"[AppDelegate] checkPendingRoomKeyRequestsInSession: Open dialog for %@", deviceInfo); self->roomKeyRequestViewController = [[RoomKeyRequestViewController alloc] initWithDeviceInfo:deviceInfo wasNewDevice:wasNewDevice andMatrixSession:mxSession onComplete:^{ @@ -3571,14 +3576,14 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni } else { - NSLog(@"[AppDelegate] checkPendingRoomKeyRequestsInSession: No details found for device %@:%@", userId, deviceId); + MXLogDebug(@"[AppDelegate] checkPendingRoomKeyRequestsInSession: No details found for device %@:%@", userId, deviceId); [mxSession.crypto ignoreAllPendingKeyRequestsFromUser:userId andDevice:deviceId onComplete:^{ [self checkPendingRoomKeyRequests]; }]; } } failure:^(NSError *error) { // Retry later - NSLog(@"[AppDelegate] checkPendingRoomKeyRequestsInSession: Failed to download device keys. Retry"); + MXLogDebug(@"[AppDelegate] checkPendingRoomKeyRequestsInSession: Failed to download device keys. Retry"); [self checkPendingRoomKeyRequests]; }]; } @@ -3626,13 +3631,13 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni { if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) { - NSLog(@"[AppDelegate][MXKeyVerification] checkPendingIncomingKeyVerificationsInSession: called while the app is not active. Ignore it."); + MXLogDebug(@"[AppDelegate][MXKeyVerification] checkPendingIncomingKeyVerificationsInSession: called while the app is not active. Ignore it."); return; } [mxSession.crypto.keyVerificationManager transactions:^(NSArray * _Nonnull transactions) { - NSLog(@"[AppDelegate][MXKeyVerification] checkPendingIncomingKeyVerificationsInSession: transactions: %@", transactions); + MXLogDebug(@"[AppDelegate][MXKeyVerification] checkPendingIncomingKeyVerificationsInSession: transactions: %@", transactions); for (MXKeyVerificationTransaction *transaction in transactions) { @@ -3665,7 +3670,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni if (!keyVerificationCoordinatorBridgePresenter.isPresenting) { - NSLog(@"[AppDelegate] presentIncomingKeyVerificationRequest"); + MXLogDebug(@"[AppDelegate] presentIncomingKeyVerificationRequest"); keyVerificationCoordinatorBridgePresenter = [[KeyVerificationCoordinatorBridgePresenter alloc] initWithSession:session]; keyVerificationCoordinatorBridgePresenter.delegate = self; @@ -3676,7 +3681,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni } else { - NSLog(@"[AppDelegate][MXKeyVerification] presentIncomingKeyVerificationRequest: Controller already presented."); + MXLogDebug(@"[AppDelegate][MXKeyVerification] presentIncomingKeyVerificationRequest: Controller already presented."); } return presented; @@ -3684,7 +3689,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni - (BOOL)presentIncomingKeyVerification:(MXIncomingSASTransaction*)transaction inSession:(MXSession*)mxSession { - NSLog(@"[AppDelegate][MXKeyVerification] presentIncomingKeyVerification: %@", transaction); + MXLogDebug(@"[AppDelegate][MXKeyVerification] presentIncomingKeyVerification: %@", transaction); BOOL presented = NO; if (!keyVerificationCoordinatorBridgePresenter.isPresenting) @@ -3698,14 +3703,14 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni } else { - NSLog(@"[AppDelegate][MXKeyVerification] presentIncomingKeyVerification: Controller already presented."); + MXLogDebug(@"[AppDelegate][MXKeyVerification] presentIncomingKeyVerification: Controller already presented."); } return presented; } - (BOOL)presentUserVerificationForRoomMember:(MXRoomMember*)roomMember session:(MXSession*)mxSession { - NSLog(@"[AppDelegate][MXKeyVerification] presentUserVerificationForRoomMember: %@", roomMember); + MXLogDebug(@"[AppDelegate][MXKeyVerification] presentUserVerificationForRoomMember: %@", roomMember); BOOL presented = NO; if (!keyVerificationCoordinatorBridgePresenter.isPresenting) @@ -3719,14 +3724,14 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni } else { - NSLog(@"[AppDelegate][MXKeyVerification] presentUserVerificationForRoomMember: Controller already presented."); + MXLogDebug(@"[AppDelegate][MXKeyVerification] presentUserVerificationForRoomMember: Controller already presented."); } return presented; } - (BOOL)presentSelfVerificationForOtherDeviceId:(NSString*)deviceId inSession:(MXSession*)mxSession { - NSLog(@"[AppDelegate][MXKeyVerification] presentSelfVerificationForOtherDeviceId: %@", deviceId); + MXLogDebug(@"[AppDelegate][MXKeyVerification] presentSelfVerificationForOtherDeviceId: %@", deviceId); BOOL presented = NO; if (!keyVerificationCoordinatorBridgePresenter.isPresenting) @@ -3740,7 +3745,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni } else { - NSLog(@"[AppDelegate][MXKeyVerification] presentUserVerificationForRoomMember: Controller already presented."); + MXLogDebug(@"[AppDelegate][MXKeyVerification] presentUserVerificationForRoomMember: Controller already presented."); } return presented; } @@ -3750,7 +3755,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni MXCrypto *crypto = coordinatorBridgePresenter.session.crypto; if (!crypto.backup.hasPrivateKeyInCryptoStore || !crypto.backup.enabled) { - NSLog(@"[AppDelegate][MXKeyVerification] requestAllPrivateKeys: Request key backup private keys"); + MXLogDebug(@"[AppDelegate][MXKeyVerification] requestAllPrivateKeys: Request key backup private keys"); [crypto setOutgoingKeyRequestsEnabled:YES onComplete:nil]; } [self dismissKeyVerificationCoordinatorBridgePresenter]; @@ -3793,7 +3798,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni if (_masterTabBarController.authenticationInProgress) { - NSLog(@"[AppDelegate][KeyVerification] keyVerificationNewRequestNotification: Postpone requests during the authentication process"); + MXLogDebug(@"[AppDelegate][KeyVerification] keyVerificationNewRequestNotification: Postpone requests during the authentication process"); // 10s is quite arbitrary dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10* NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ @@ -3817,7 +3822,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni MXRoom *room = [currentAccount.mxSession roomWithRoomId:keyVerificationByDMRequest.roomId]; if (!room) { - NSLog(@"[AppDelegate][KeyVerification] keyVerificationRequestDidChangeNotification: Unknown room"); + MXLogDebug(@"[AppDelegate][KeyVerification] keyVerificationRequestDidChangeNotification: Unknown room"); return; } @@ -3841,11 +3846,11 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni if (keyVerificationByToDeviceRequest.isFromMyUser) { // Self verification - NSLog(@"[AppDelegate][KeyVerification] keyVerificationNewRequestNotification: Self verification from %@", keyVerificationByToDeviceRequest.otherDevice); + MXLogDebug(@"[AppDelegate][KeyVerification] keyVerificationNewRequestNotification: Self verification from %@", keyVerificationByToDeviceRequest.otherDevice); if (!self.handleSelfVerificationRequest) { - NSLog(@"[AppDelegate][KeyVerification] keyVerificationNewRequestNotification: Self verification handled elsewhere"); + MXLogDebug(@"[AppDelegate][KeyVerification] keyVerificationNewRequestNotification: Self verification handled elsewhere"); return; } @@ -3863,7 +3868,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni { // Device verification from other user // This happens when they or our user do not have cross-signing enabled - NSLog(@"[AppDelegate][KeyVerification] keyVerificationNewRequestNotification: Device verification from other user %@:%@", keyVerificationByToDeviceRequest.otherUser, keyVerificationByToDeviceRequest.otherDevice); + MXLogDebug(@"[AppDelegate][KeyVerification] keyVerificationNewRequestNotification: Device verification from other user %@:%@", keyVerificationByToDeviceRequest.otherUser, keyVerificationByToDeviceRequest.otherDevice); NSString *myUserId = keyVerificationByToDeviceRequest.to; NSString *userId = keyVerificationByToDeviceRequest.otherUser; @@ -3879,7 +3884,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni } else { - NSLog(@"[AppDelegate][KeyVerification] keyVerificationNewRequestNotification. Bad request state: %@", keyVerificationByToDeviceRequest); + MXLogDebug(@"[AppDelegate][KeyVerification] keyVerificationNewRequestNotification. Bad request state: %@", keyVerificationByToDeviceRequest); } } } @@ -3891,7 +3896,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni { if (keyVerificationRequest.state != MXKeyVerificationRequestStatePending) { - NSLog(@"[AppDelegate] presentNewKeyVerificationRequest: Request already accepted. Do not display it"); + MXLogDebug(@"[AppDelegate] presentNewKeyVerificationRequest: Request already accepted. Do not display it"); return; } @@ -3905,7 +3910,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni { // If it is a self verification for my device, we can discard the new signin alert. // Note: It will not work well with several devices to verify at the same time. - NSLog(@"[AppDelegate] presentNewKeyVerificationRequest: Remove the alert for new sign in detected"); + MXLogDebug(@"[AppDelegate] presentNewKeyVerificationRequest: Remove the alert for new sign in detected"); [self.userNewSignInAlertController dismissViewControllerAnimated:NO completion:^{ self.userNewSignInAlertController = nil; [self presentNewKeyVerificationRequestAlertForSession:session senderName:senderName senderId:senderId request:keyVerificationRequest]; @@ -3953,7 +3958,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni [keyVerificationRequest cancelWithCancelCode:MXTransactionCancelCode.user success:^{ } failure:^(NSError * _Nonnull error) { - NSLog(@"[AppDelegate][KeyVerification] Fail to cancel incoming key verification request with error: %@", error); + MXLogDebug(@"[AppDelegate][KeyVerification] Fail to cancel incoming key verification request with error: %@", error); }]; }]]; @@ -4024,14 +4029,14 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni } } failure:^(NSError *error) { - NSLog(@"[AppDelegate][NewSignIn] Fail to fetch devices"); + MXLogDebug(@"[AppDelegate][NewSignIn] Fail to fetch devices"); }]; }]; } - (void)presentNewSignInAlertForDevice:(MXDevice*)device inSession:(MXSession*)session { - NSLog(@"[AppDelegate] presentNewSignInAlertForDevice: %@", device.deviceId); + MXLogDebug(@"[AppDelegate] presentNewSignInAlertForDevice: %@", device.deviceId); if (self.userNewSignInAlertController) { @@ -4095,11 +4100,11 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni MXStrongifyAndReturnIfNil(self); - NSLog(@"[AppDelegate] registerDidChangeCrossSigningKeysNotificationForSession"); + MXLogDebug(@"[AppDelegate] registerDidChangeCrossSigningKeysNotificationForSession"); if (self.userNewSignInAlertController) { - NSLog(@"[AppDelegate] registerDidChangeCrossSigningKeysNotificationForSession: Hide NewSignInAlertController"); + MXLogDebug(@"[AppDelegate] registerDidChangeCrossSigningKeysNotificationForSession: Hide NewSignInAlertController"); [self.userNewSignInAlertController dismissViewControllerAnimated:NO completion:^{ [self.masterTabBarController presentVerifyCurrentSessionAlertIfNeededWithSession:session]; @@ -4118,7 +4123,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni - (BOOL)presentCompleteSecurityForSession:(MXSession*)mxSession { - NSLog(@"[AppDelegate][MXKeyVerification] presentCompleteSecurityForSession"); + MXLogDebug(@"[AppDelegate][MXKeyVerification] presentCompleteSecurityForSession"); BOOL presented = NO; if (!keyVerificationCoordinatorBridgePresenter.isPresenting) @@ -4132,7 +4137,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni } else { - NSLog(@"[AppDelegate][MXKeyVerification] presentCompleteSecurityForSession: Controller already presented."); + MXLogDebug(@"[AppDelegate][MXKeyVerification] presentCompleteSecurityForSession: Controller already presented."); } return presented; } @@ -4255,7 +4260,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni - (void)handleIdentityServiceTermsNotSignedNotification:(NSNotification*)notification { - NSLog(@"[AppDelegate] IS Terms: handleIdentityServiceTermsNotSignedNotification."); + MXLogDebug(@"[AppDelegate] IS Terms: handleIdentityServiceTermsNotSignedNotification."); NSString *baseURL; NSString *accessToken; @@ -4297,14 +4302,14 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni - (void)serviceTermsModalCoordinatorBridgePresenterDelegateDidDecline:(ServiceTermsModalCoordinatorBridgePresenter *)coordinatorBridgePresenter session:(MXSession *)session { - NSLog(@"[AppDelegate] IS Terms: User has declined the use of the default IS."); + MXLogDebug(@"[AppDelegate] IS Terms: User has declined the use of the default IS."); // The user does not want to use the proposed IS. // Disable IS feature on user's account [session setIdentityServer:nil andAccessToken:nil]; [session setAccountDataIdentityServer:nil success:^{ } failure:^(NSError *error) { - NSLog(@"[AppDelegate] IS Terms: Error: %@", error); + MXLogDebug(@"[AppDelegate] IS Terms: Error: %@", error); }]; [coordinatorBridgePresenter dismissWithAnimated:YES completion:^{ @@ -4617,7 +4622,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni if (!authVC) { - NSLog(@"[AppDelegate] Fail to continue SSO login"); + MXLogDebug(@"[AppDelegate] Fail to continue SSO login"); return NO; } diff --git a/Riot/Modules/Authentication/AuthenticationViewController.m b/Riot/Modules/Authentication/AuthenticationViewController.m index 48e73eda0..b7a64071f 100644 --- a/Riot/Modules/Authentication/AuthenticationViewController.m +++ b/Riot/Modules/Authentication/AuthenticationViewController.m @@ -329,7 +329,7 @@ static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0; { didCheckFalseAuthScreenDisplay = YES; - NSLog(@"[AuthenticationVC] viewDidAppear: Checking false logout"); + MXLogDebug(@"[AuthenticationVC] viewDidAppear: Checking false logout"); [[MXKAccountManager sharedManager] forceReloadAccounts]; if ([MXKAccountManager sharedManager].activeAccounts.count) { @@ -595,7 +595,7 @@ static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0; return YES; } - NSLog(@"[AuthenticationVC] Fail to continue SSO login"); + MXLogDebug(@"[AuthenticationVC] Fail to continue SSO login"); return NO; } @@ -747,11 +747,11 @@ static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0; - (void)clearDataAfterSoftLogout { - NSLog(@"[AuthenticationVC] clearDataAfterSoftLogout %@", self.softLogoutCredentials.userId); + MXLogDebug(@"[AuthenticationVC] clearDataAfterSoftLogout %@", self.softLogoutCredentials.userId); // Use AppDelegate so that we reset app settings and this auth screen [[AppDelegate theDelegate] logoutSendingRequestServer:YES completion:^(BOOL isLoggedOut) { - NSLog(@"[AuthenticationVC] Complete. isLoggedOut: %@", @(isLoggedOut)); + MXLogDebug(@"[AuthenticationVC] Complete. isLoggedOut: %@", @(isLoggedOut)); }]; } @@ -772,7 +772,7 @@ static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0; // Remove known flows we do not support if (![flow.type isEqualToString:kMXLoginFlowTypeToken]) { - NSLog(@"[AuthenticationVC] handleSupportedFlowsInAuthenticationSession: Filter out flow %@", flow.type); + MXLogDebug(@"[AuthenticationVC] handleSupportedFlowsInAuthenticationSession: Filter out flow %@", flow.type); [supportedFlows addObject:flow]; } @@ -783,7 +783,7 @@ static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0; if ([flow isKindOfClass:MXLoginSSOFlow.class]) { - NSLog(@"[AuthenticationVC] handleSupportedFlowsInAuthenticationSession: Prioritise flow %@", flow.type); + MXLogDebug(@"[AuthenticationVC] handleSupportedFlowsInAuthenticationSession: Prioritise flow %@", flow.type); ssoFlow = (MXLoginSSOFlow *)flow; } } @@ -986,7 +986,7 @@ static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0; // - the username is not already in use if ([mxError.errcode isEqualToString:kMXErrCodeStringUserInUse]) { - NSLog(@"[AuthenticationVC] User name is already use"); + MXLogDebug(@"[AuthenticationVC] User name is already use"); [self onFailureDuringAuthRequest:[NSError errorWithDomain:MXKAuthErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey:[NSBundle mxk_localizedStringForKey:@"auth_username_in_use"]}]]; } // - the server quota limits is not reached @@ -1325,14 +1325,14 @@ static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0; - (void)showResourceLimitExceededError:(NSDictionary *)errorDict { - NSLog(@"[AuthenticationVC] showResourceLimitExceededError"); + MXLogDebug(@"[AuthenticationVC] showResourceLimitExceededError"); [self showResourceLimitExceededError:errorDict onAdminContactTapped:^(NSURL *adminContactURL) { [[UIApplication sharedApplication] vc_open:adminContactURL completionHandler:^(BOOL success) { if (!success) { - NSLog(@"[AuthenticationVC] adminContact(%@) cannot be opened", adminContactURL); + MXLogDebug(@"[AuthenticationVC] adminContact(%@) cannot be opened", adminContactURL); } }]; }]; @@ -1381,7 +1381,7 @@ static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0; { MXRoomCreationParameters *roomCreationParameters = [MXRoomCreationParameters parametersForDirectRoomWithUser:@"@riot-bot:matrix.org"]; [session createRoomWithParameters:roomCreationParameters success:nil failure:^(NSError *error) { - NSLog(@"[AuthenticationVC] Create chat with riot-bot failed"); + MXLogDebug(@"[AuthenticationVC] Create chat with riot-bot failed"); }]; } @@ -1421,7 +1421,7 @@ static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0; { [session.crypto.crossSigning refreshStateWithSuccess:^(BOOL stateUpdated) { - NSLog(@"[AuthenticationVC] sessionStateDidChange: crossSigning.state: %@", @(session.crypto.crossSigning.state)); + MXLogDebug(@"[AuthenticationVC] sessionStateDidChange: crossSigning.state: %@", @(session.crypto.crossSigning.state)); switch (session.crypto.crossSigning.state) { @@ -1436,13 +1436,13 @@ static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0; // We do it for both registration and new login as long as cross-signing does not exist yet if (self.authInputsView.password.length) { - NSLog(@"[AuthenticationVC] sessionStateDidChange: Bootstrap with password"); + MXLogDebug(@"[AuthenticationVC] sessionStateDidChange: Bootstrap with password"); [session.crypto.crossSigning setupWithPassword:self.authInputsView.password success:^{ - NSLog(@"[AuthenticationVC] sessionStateDidChange: Bootstrap succeeded"); + MXLogDebug(@"[AuthenticationVC] sessionStateDidChange: Bootstrap succeeded"); [self dismiss]; } failure:^(NSError * _Nonnull error) { - NSLog(@"[AuthenticationVC] sessionStateDidChange: Bootstrap failed. Error: %@", error); + MXLogDebug(@"[AuthenticationVC] sessionStateDidChange: Bootstrap failed. Error: %@", error); [session.crypto setOutgoingKeyRequestsEnabled:YES onComplete:nil]; [self dismiss]; }]; @@ -1451,10 +1451,10 @@ static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0; { // Try to setup cross-signing without authentication parameters in case if a grace period is enabled [self.crossSigningService setupCrossSigningWithoutAuthenticationFor:session success:^{ - NSLog(@"[AuthenticationVC] sessionStateDidChange: Bootstrap succeeded without credentials"); + MXLogDebug(@"[AuthenticationVC] sessionStateDidChange: Bootstrap succeeded without credentials"); [self dismiss]; } failure:^(NSError * _Nonnull error) { - NSLog(@"[AuthenticationVC] sessionStateDidChange: Do not know how to bootstrap cross-signing. Skip it."); + MXLogDebug(@"[AuthenticationVC] sessionStateDidChange: Do not know how to bootstrap cross-signing. Skip it."); [session.crypto setOutgoingKeyRequestsEnabled:YES onComplete:nil]; [self dismiss]; }]; @@ -1469,7 +1469,7 @@ static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0; } case MXCrossSigningStateCrossSigningExists: { - NSLog(@"[AuthenticationVC] sessionStateDidChange: Complete security"); + MXLogDebug(@"[AuthenticationVC] sessionStateDidChange: Complete security"); // Ask the user to verify this session self.userInteractionEnabled = YES; @@ -1480,7 +1480,7 @@ static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0; } default: - NSLog(@"[AuthenticationVC] sessionStateDidChange: Nothing to do"); + MXLogDebug(@"[AuthenticationVC] sessionStateDidChange: Nothing to do"); [session.crypto setOutgoingKeyRequestsEnabled:YES onComplete:nil]; [self dismiss]; @@ -1488,7 +1488,7 @@ static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0; } } failure:^(NSError * _Nonnull error) { - NSLog(@"[AuthenticationVC] sessionStateDidChange: Fail to refresh crypto state with error: %@", error); + MXLogDebug(@"[AuthenticationVC] sessionStateDidChange: Fail to refresh crypto state with error: %@", error); [session.crypto setOutgoingKeyRequestsEnabled:YES onComplete:nil]; [self dismiss]; }]; @@ -1636,7 +1636,7 @@ static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0; MXCrypto *crypto = coordinatorBridgePresenter.session.crypto; if (!crypto.backup.hasPrivateKeyInCryptoStore || !crypto.backup.enabled) { - NSLog(@"[AuthenticationVC][MXKeyVerification] requestAllPrivateKeys: Request key backup private keys"); + MXLogDebug(@"[AuthenticationVC][MXKeyVerification] requestAllPrivateKeys: Request key backup private keys"); [crypto setOutgoingKeyRequestsEnabled:YES onComplete:nil]; } [self dismiss]; diff --git a/Riot/Modules/Authentication/SSO/SSOAuthenticationPresenter.swift b/Riot/Modules/Authentication/SSO/SSOAuthenticationPresenter.swift index 21084d92a..3a0b202ec 100644 --- a/Riot/Modules/Authentication/SSO/SSOAuthenticationPresenter.swift +++ b/Riot/Modules/Authentication/SSO/SSOAuthenticationPresenter.swift @@ -140,7 +140,7 @@ final class SSOAuthenticationPresenter: NSObject { if let loginToken = self.ssoAuthenticationService.loginToken(from: successURL) { self.delegate?.ssoAuthenticationPresenter(self, authenticationSucceededWithToken: loginToken) } else { - NSLog("SSOAuthenticationPresenter: Login token not found") + MXLog.debug("SSOAuthenticationPresenter: Login token not found") self.delegate?.ssoAuthenticationPresenter(self, authenticationDidFailWithError: SSOAuthenticationServiceError.tokenNotFound) } } diff --git a/Riot/Modules/Authentication/Views/AuthInputsView.m b/Riot/Modules/Authentication/Views/AuthInputsView.m index d944b017d..5d869a341 100644 --- a/Riot/Modules/Authentication/Views/AuthInputsView.m +++ b/Riot/Modules/Authentication/Views/AuthInputsView.m @@ -290,7 +290,7 @@ // Check required fields if ((!self.userLoginTextField.text.length && !nbPhoneNumber) || !self.passWordTextField.text.length) { - NSLog(@"[AuthInputsView] Invalid user/password"); + MXLogDebug(@"[AuthInputsView] Invalid user/password"); errorMsg = NSLocalizedStringFromTable(@"auth_invalid_login_param", @"Vector", nil); } } @@ -305,22 +305,22 @@ { if (!self.userLoginTextField.text.length) { - NSLog(@"[AuthInputsView] Invalid user name"); + MXLogDebug(@"[AuthInputsView] Invalid user name"); errorMsg = NSLocalizedStringFromTable(@"auth_invalid_user_name", @"Vector", nil); } else if (!self.passWordTextField.text.length) { - NSLog(@"[AuthInputsView] Missing Passwords"); + MXLogDebug(@"[AuthInputsView] Missing Passwords"); errorMsg = NSLocalizedStringFromTable(@"auth_missing_password", @"Vector", nil); } else if (self.passWordTextField.text.length < 6) { - NSLog(@"[AuthInputsView] Invalid Passwords"); + MXLogDebug(@"[AuthInputsView] Invalid Passwords"); errorMsg = NSLocalizedStringFromTable(@"auth_invalid_password", @"Vector", nil); } else if ([self.repeatPasswordTextField.text isEqualToString:self.passWordTextField.text] == NO) { - NSLog(@"[AuthInputsView] Passwords don't match"); + MXLogDebug(@"[AuthInputsView] Passwords don't match"); errorMsg = NSLocalizedStringFromTable(@"auth_password_dont_match", @"Vector", nil); } else @@ -331,7 +331,7 @@ if ([regex firstMatchInString:user options:0 range:NSMakeRange(0, user.length)] == nil) { - NSLog(@"[AuthInputsView] Invalid user name"); + MXLogDebug(@"[AuthInputsView] Invalid user name"); errorMsg = NSLocalizedStringFromTable(@"auth_invalid_user_name", @"Vector", nil); } } @@ -343,12 +343,12 @@ { if (self.areAllThirdPartyIdentifiersRequired) { - NSLog(@"[AuthInputsView] Missing email"); + MXLogDebug(@"[AuthInputsView] Missing email"); errorMsg = NSLocalizedStringFromTable(@"auth_missing_email", @"Vector", nil); } else if ([self isFlowSupported:kMXLoginFlowTypeMSISDN] && !self.phoneTextField.text.length && self.isThirdPartyIdentifierRequired) { - NSLog(@"[AuthInputsView] Missing email or phone number"); + MXLogDebug(@"[AuthInputsView] Missing email or phone number"); errorMsg = NSLocalizedStringFromTable(@"auth_missing_email_or_phone", @"Vector", nil); } } @@ -360,7 +360,7 @@ { if (self.areAllThirdPartyIdentifiersRequired) { - NSLog(@"[AuthInputsView] Missing phone"); + MXLogDebug(@"[AuthInputsView] Missing phone"); errorMsg = NSLocalizedStringFromTable(@"auth_missing_phone", @"Vector", nil); } } @@ -373,7 +373,7 @@ // Check validity of the non empty email if (![MXTools isEmailAddress:self.emailTextField.text]) { - NSLog(@"[AuthInputsView] Invalid email"); + MXLogDebug(@"[AuthInputsView] Invalid email"); errorMsg = NSLocalizedStringFromTable(@"auth_invalid_email", @"Vector", nil); } } @@ -383,7 +383,7 @@ // Check validity of the non empty phone if (![[NBPhoneNumberUtil sharedInstance] isValidNumber:nbPhoneNumber]) { - NSLog(@"[AuthInputsView] Invalid phone number"); + MXLogDebug(@"[AuthInputsView] Invalid phone number"); errorMsg = NSLocalizedStringFromTable(@"auth_invalid_phone", @"Vector", nil); } } @@ -403,7 +403,7 @@ if (externalRegistrationParameters) { // We trigger here a registration based on external inputs. All the required data are handled by the session id. - NSLog(@"[AuthInputsView] prepareParameters: return external registration parameters"); + MXLogDebug(@"[AuthInputsView] prepareParameters: return external registration parameters"); callback(externalRegistrationParameters, nil); // CAUTION: Do not reset this dictionary here, it is used later to handle this registration until the end (see [updateAuthSessionWithCompletedStages:didUpdateParameters:]) @@ -522,7 +522,7 @@ // Check whether a phone number has been set, and if it is not handled yet if (nbPhoneNumber && ![self isFlowCompleted:kMXLoginFlowTypeMSISDN]) { - NSLog(@"[AuthInputsView] Prepare msisdn stage"); + MXLogDebug(@"[AuthInputsView] Prepare msisdn stage"); // Retrieve the REST client from delegate MXRestClient *restClient; @@ -576,7 +576,7 @@ failure:^(NSError *error) { - NSLog(@"[AuthInputsView] Failed to request msisdn token"); + MXLogDebug(@"[AuthInputsView] Failed to request msisdn token"); // Ignore connection cancellation error if (([error.domain isEqualToString:NSURLErrorDomain] && error.code == NSURLErrorCancelled)) @@ -626,12 +626,12 @@ // Async response return; } - NSLog(@"[AuthInputsView] Authentication failed during the msisdn stage"); + MXLogDebug(@"[AuthInputsView] Authentication failed during the msisdn stage"); } // Check whether an email has been set, and if it is not handled yet else if (!self.emailContainer.isHidden && self.emailTextField.text.length && ![self isFlowCompleted:kMXLoginFlowTypeEmailIdentity]) { - NSLog(@"[AuthInputsView] Prepare email identity stage"); + MXLogDebug(@"[AuthInputsView] Prepare email identity stage"); // Retrieve the REST client from delegate MXRestClient *restClient; @@ -702,7 +702,7 @@ failure:^(NSError *error) { - NSLog(@"[AuthInputsView] Failed to request email token"); + MXLogDebug(@"[AuthInputsView] Failed to request email token"); // Ignore connection cancellation error if (([error.domain isEqualToString:NSURLErrorDomain] && error.code == NSURLErrorCancelled)) @@ -749,11 +749,11 @@ // Async response return; } - NSLog(@"[AuthInputsView] Authentication failed during the email identity stage"); + MXLogDebug(@"[AuthInputsView] Authentication failed during the email identity stage"); } else if ([self isFlowSupported:kMXLoginFlowTypeRecaptcha] && ![self isFlowCompleted:kMXLoginFlowTypeRecaptcha]) { - NSLog(@"[AuthInputsView] Prepare reCaptcha stage"); + MXLogDebug(@"[AuthInputsView] Prepare reCaptcha stage"); [self displayRecaptchaForm:^(NSString *response) { @@ -773,7 +773,7 @@ } else { - NSLog(@"[AuthInputsView] reCaptcha stage failed"); + MXLogDebug(@"[AuthInputsView] reCaptcha stage failed"); callback(nil, [NSError errorWithDomain:MXKAuthErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey:[NSBundle mxk_localizedStringForKey:@"not_supported_yet"]}]); } @@ -807,7 +807,7 @@ } else if ([self isFlowSupported:kMXLoginFlowTypeTerms] && ![self isFlowCompleted:kMXLoginFlowTypeTerms]) { - NSLog(@"[AuthInputsView] Prepare terms stage"); + MXLogDebug(@"[AuthInputsView] Prepare terms stage"); MXWeakify(self); [self displayTermsView:^{ @@ -848,7 +848,7 @@ // Check the supported use cases if (isMSISDNFlowCompleted && self.isThirdPartyIdentifierPending) { - NSLog(@"[AuthInputsView] Prepare a new third-party stage"); + MXLogDebug(@"[AuthInputsView] Prepare a new third-party stage"); // Here an email address is available, we add it to the authentication session. [self prepareParameters:callback]; @@ -858,7 +858,7 @@ else if ((isMSISDNFlowCompleted || isEmailFlowCompleted) && [self isFlowSupported:kMXLoginFlowTypeRecaptcha] && ![self isFlowCompleted:kMXLoginFlowTypeRecaptcha]) { - NSLog(@"[AuthInputsView] Display reCaptcha stage"); + MXLogDebug(@"[AuthInputsView] Display reCaptcha stage"); if (externalRegistrationParameters) { @@ -874,7 +874,7 @@ } else { - NSLog(@"[AuthInputsView] reCaptcha stage failed"); + MXLogDebug(@"[AuthInputsView] reCaptcha stage failed"); callback (nil, [NSError errorWithDomain:MXKAuthErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey:[NSBundle mxk_localizedStringForKey:@"not_supported_yet"]}]); } }]; @@ -888,7 +888,7 @@ } else if ([self isFlowSupported:kMXLoginFlowTypeTerms] && ![self isFlowCompleted:kMXLoginFlowTypeTerms]) { - NSLog(@"[AuthInputsView] Prepare a new terms stage"); + MXLogDebug(@"[AuthInputsView] Prepare a new terms stage"); if (externalRegistrationParameters) { @@ -912,7 +912,7 @@ } } - NSLog(@"[AuthInputsView] updateAuthSessionWithCompletedStages failed"); + MXLogDebug(@"[AuthInputsView] updateAuthSessionWithCompletedStages failed"); callback (nil, [NSError errorWithDomain:MXKAuthErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey:[NSBundle mxk_localizedStringForKey:@"not_supported_yet"]}]); } } @@ -926,7 +926,7 @@ // Check the current authentication type if (self.authType != MXKAuthenticationTypeRegister) { - NSLog(@"[AuthInputsView] setExternalRegistrationParameters failed: wrong auth type"); + MXLogDebug(@"[AuthInputsView] setExternalRegistrationParameters failed: wrong auth type"); return NO; } @@ -947,7 +947,7 @@ if ([homeserverURL isEqualToString:restClient.homeserver] == NO) { - NSLog(@"[AuthInputsView] setExternalRegistrationParameters failed: wrong homeserver URL"); + MXLogDebug(@"[AuthInputsView] setExternalRegistrationParameters failed: wrong homeserver URL"); return NO; } } @@ -960,14 +960,14 @@ if ([identityURL isEqualToString:restClient.identityServer] == NO) { - NSLog(@"[AuthInputsView] setExternalRegistrationParameters failed: wrong identity server URL"); + MXLogDebug(@"[AuthInputsView] setExternalRegistrationParameters failed: wrong identity server URL"); return NO; } } } else { - NSLog(@"[AuthInputsView] setExternalRegistrationParameters failed: not supported"); + MXLogDebug(@"[AuthInputsView] setExternalRegistrationParameters failed: not supported"); return NO; } @@ -995,7 +995,7 @@ // Check validity of the required parameters if (!homeserverURL.length || !clientSecret.length || !sid.length || !sessionId.length) { - NSLog(@"[AuthInputsView] setExternalRegistrationParameters failed: wrong parameters"); + MXLogDebug(@"[AuthInputsView] setExternalRegistrationParameters failed: wrong parameters"); return NO; } @@ -1052,7 +1052,7 @@ [self displaySoftLogoutMessageWithUserDisplayname:myUser.displayname andKeyBackupNeeded:keyBackupNeeded]; } failure:^(NSError * _Nonnull error) { - NSLog(@"[AuthInputsView] displaySoftLogoutMessage: Cannot load displayname. Error: %@", error); + MXLogDebug(@"[AuthInputsView] displaySoftLogoutMessage: Cannot load displayname. Error: %@", error); [self displaySoftLogoutMessageWithUserDisplayname:nil andKeyBackupNeeded:keyBackupNeeded]; }]; } @@ -1590,7 +1590,7 @@ { if ([self isSupportedFlowType:stage] == NO) { - NSLog(@"[AuthInputsView] %@: %@ stage is not supported.", (type == MXKAuthenticationTypeLogin ? @"login" : @"register"), stage); + MXLogDebug(@"[AuthInputsView] %@: %@ stage is not supported.", (type == MXKAuthenticationTypeLogin ? @"login" : @"register"), stage); isSupported = NO; break; } @@ -1608,7 +1608,7 @@ } else { - NSLog(@"[AuthInputsView] %@: %@ stage is not supported.", (type == MXKAuthenticationTypeLogin ? @"login" : @"register"), flow.type); + MXLogDebug(@"[AuthInputsView] %@: %@ stage is not supported.", (type == MXKAuthenticationTypeLogin ? @"login" : @"register"), flow.type); } } else @@ -1621,7 +1621,7 @@ { if ([self isSupportedFlowType:stage] == NO) { - NSLog(@"[AuthInputsView] %@: %@ stage is not supported.", (type == MXKAuthenticationTypeLogin ? @"login" : @"register"), stage); + MXLogDebug(@"[AuthInputsView] %@: %@ stage is not supported.", (type == MXKAuthenticationTypeLogin ? @"login" : @"register"), stage); isSupported = NO; break; } @@ -1744,12 +1744,12 @@ } else { - NSLog(@"[AuthInputsView] Failed to retrieve identity server URL"); + MXLogDebug(@"[AuthInputsView] Failed to retrieve identity server URL"); } } failure:^(NSError *error) { - NSLog(@"[AuthInputsView] Failed to submit the sms token"); + MXLogDebug(@"[AuthInputsView] Failed to submit the sms token"); // Ignore connection cancellation error if (([error.domain isEqualToString:NSURLErrorDomain] && error.code == NSURLErrorCancelled)) @@ -1877,7 +1877,7 @@ { [mxRestClient supportedMatrixVersions:^(MXMatrixVersions *matrixVersions) { - NSLog(@"[AuthInputsView] checkIdentityServerRequirement: %@", matrixVersions.doesServerRequireIdentityServerParam ? @"YES": @"NO"); + MXLogDebug(@"[AuthInputsView] checkIdentityServerRequirement: %@", matrixVersions.doesServerRequireIdentityServerParam ? @"YES": @"NO"); success(matrixVersions.doesServerRequireIdentityServerParam); } failure:failure]; diff --git a/Riot/Modules/Authentication/Views/ForgotPasswordInputsView.m b/Riot/Modules/Authentication/Views/ForgotPasswordInputsView.m index e45d67397..b6deda549 100644 --- a/Riot/Modules/Authentication/Views/ForgotPasswordInputsView.m +++ b/Riot/Modules/Authentication/Views/ForgotPasswordInputsView.m @@ -165,22 +165,22 @@ if (!self.emailTextField.text.length) { - NSLog(@"[ForgotPasswordInputsView] Missing email"); + MXLogDebug(@"[ForgotPasswordInputsView] Missing email"); errorMsg = NSLocalizedStringFromTable(@"auth_reset_password_missing_email", @"Vector", nil); } else if (!self.passWordTextField.text.length) { - NSLog(@"[ForgotPasswordInputsView] Missing Passwords"); + MXLogDebug(@"[ForgotPasswordInputsView] Missing Passwords"); errorMsg = NSLocalizedStringFromTable(@"auth_reset_password_missing_password", @"Vector", nil); } else if (self.passWordTextField.text.length < 6) { - NSLog(@"[ForgotPasswordInputsView] Invalid Passwords"); + MXLogDebug(@"[ForgotPasswordInputsView] Invalid Passwords"); errorMsg = NSLocalizedStringFromTable(@"auth_invalid_password", @"Vector", nil); } else if ([self.repeatPasswordTextField.text isEqualToString:self.passWordTextField.text] == NO) { - NSLog(@"[ForgotPasswordInputsView] Passwords don't match"); + MXLogDebug(@"[ForgotPasswordInputsView] Passwords don't match"); errorMsg = NSLocalizedStringFromTable(@"auth_password_dont_match", @"Vector", nil); } else @@ -188,7 +188,7 @@ // Check validity of the non empty email if ([MXTools isEmailAddress:self.emailTextField.text] == NO) { - NSLog(@"[ForgotPasswordInputsView] Invalid email"); + MXLogDebug(@"[ForgotPasswordInputsView] Invalid email"); errorMsg = NSLocalizedStringFromTable(@"auth_invalid_email", @"Vector", nil); } } @@ -285,7 +285,7 @@ } failure:^(NSError *error) { - NSLog(@"[ForgotPasswordInputsView] Failed to request email token"); + MXLogDebug(@"[ForgotPasswordInputsView] Failed to request email token"); // Ignore connection cancellation error if (([error.domain isEqualToString:NSURLErrorDomain] && error.code == NSURLErrorCancelled)) @@ -345,7 +345,7 @@ } else { - NSLog(@"[ForgotPasswordInputsView] Operation failed during the email identity stage"); + MXLogDebug(@"[ForgotPasswordInputsView] Operation failed during the email identity stage"); } } @@ -414,7 +414,7 @@ { [mxRestClient supportedMatrixVersions:^(MXMatrixVersions *matrixVersions) { - NSLog(@"[ForgotPasswordInputsView] checkIdentityServerRequirement: %@", matrixVersions.doesServerRequireIdentityServerParam ? @"YES": @"NO"); + MXLogDebug(@"[ForgotPasswordInputsView] checkIdentityServerRequirement: %@", matrixVersions.doesServerRequireIdentityServerParam ? @"YES": @"NO"); if (matrixVersions.doesServerRequireIdentityServerParam && !mxRestClient.identityServer) diff --git a/Riot/Modules/Call/CallViewController.m b/Riot/Modules/Call/CallViewController.m index bfcf9d46c..631936080 100644 --- a/Riot/Modules/Call/CallViewController.m +++ b/Riot/Modules/Call/CallViewController.m @@ -575,7 +575,7 @@ duration:0 interToneGap:0]; - NSLog(@"[CallViewController] Sending DTMF tones %@", result ? @"succeeded": @"failed"); + MXLogDebug(@"[CallViewController] Sending DTMF tones %@", result ? @"succeeded": @"failed"); } #pragma mark - CallTransferMainViewControllerDelegate @@ -615,9 +615,9 @@ withTransferee:transfereeUser consultFirst:consult success:^(NSString * _Nonnull newCallId){ - NSLog(@"Call transfer succeeded with new call ID: %@", newCallId); + MXLogDebug(@"Call transfer succeeded with new call ID: %@", newCallId); } failure:^(NSError * _Nullable error) { - NSLog(@"Call transfer failed with error: %@", error); + MXLogDebug(@"Call transfer failed with error: %@", error); failureBlock(error); }]; }; diff --git a/Riot/Modules/Camera/CameraAccessAlertPresenter.swift b/Riot/Modules/Camera/CameraAccessAlertPresenter.swift index 8005890c9..34c30408f 100644 --- a/Riot/Modules/Camera/CameraAccessAlertPresenter.swift +++ b/Riot/Modules/Camera/CameraAccessAlertPresenter.swift @@ -36,7 +36,7 @@ final class CameraAccessAlertPresenter { let settingsAction = UIAlertAction(title: settingsActionTitle, style: .default, handler: { _ in UIApplication.shared.open(settingsURL, options: [:], completionHandler: { (succeed) in if !succeed { - print("[CameraPresenter] Fails to open settings") + MXLog.debug("[CameraPresenter] Fails to open settings") } }) }) diff --git a/Riot/Modules/Common/NavigationController/RiotNavigationController.m b/Riot/Modules/Common/NavigationController/RiotNavigationController.m index 44d34c921..98f098d43 100644 --- a/Riot/Modules/Common/NavigationController/RiotNavigationController.m +++ b/Riot/Modules/Common/NavigationController/RiotNavigationController.m @@ -14,6 +14,8 @@ limitations under the License. */ +@import MatrixSDK; + #import "RiotNavigationController.h" @implementation RiotNavigationController @@ -59,7 +61,7 @@ { if ([self.viewControllers indexOfObject:viewController] != NSNotFound) { - NSLog(@"[RiotNavigationController] pushViewController: is pushing same view controller %@\n%@", viewController, [NSThread callStackSymbols]); + MXLogDebug(@"[RiotNavigationController] pushViewController: is pushing same view controller %@\n%@", viewController, [NSThread callStackSymbols]); return; } [super pushViewController:viewController animated:animated]; diff --git a/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m b/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m index bc879a7eb..207e1975f 100644 --- a/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m +++ b/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m @@ -195,7 +195,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou && self.mxSession.crypto.backup.hasKeysToBackup && self.mxSession.crypto.backup.state == MXKeyBackupStateDisabled) { - NSLog(@"[RecentsDataSource] updateSecureBackupBanner: Secure backup should be shown (crypto.backup.state = %lu)", (unsigned long)self.mxSession.crypto.backup.state); + MXLogDebug(@"[RecentsDataSource] updateSecureBackupBanner: Secure backup should be shown (crypto.backup.state = %lu)", (unsigned long)self.mxSession.crypto.backup.state); secureBackupBanner = SecureBackupBannerDisplaySetup; } } @@ -240,7 +240,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou [self updateCrossSigningBannerDisplay:crossSigningBannerDisplay]; } failure:^(NSError * _Nonnull error) { - NSLog(@"[RecentsDataSource] refreshCrossSigningBannerDisplay: Fail to verify if cross signing banner can be displayed"); + MXLogDebug(@"[RecentsDataSource] refreshCrossSigningBannerDisplay: Fail to verify if cross signing banner can be displayed"); }]; } else @@ -1456,7 +1456,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou } } - NSLog(@"[RecentsDataSource] refreshRoomsSections: Done in %.0fms", [[NSDate date] timeIntervalSinceDate:startDate] * 1000); + MXLogDebug(@"[RecentsDataSource] refreshRoomsSections: Done in %.0fms", [[NSDate date] timeIntervalSinceDate:startDate] * 1000); } - (void)dataSource:(MXKDataSource*)dataSource didCellChange:(id)changes @@ -1618,7 +1618,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou - (void)moveRoomCell:(MXRoom*)room from:(NSIndexPath*)oldPath to:(NSIndexPath*)newPath success:(void (^)(void))moveSuccess failure:(void (^)(NSError *error))moveFailure; { - NSLog(@"[RecentsDataSource] moveCellFrom (%tu, %tu) to (%tu, %tu)", oldPath.section, oldPath.row, newPath.section, newPath.row); + MXLogDebug(@"[RecentsDataSource] moveCellFrom (%tu, %tu) to (%tu, %tu)", oldPath.section, oldPath.row, newPath.section, newPath.row); if ([self canCellMoveFrom:oldPath to:newPath] && ![newPath isEqual:oldPath]) { @@ -1629,7 +1629,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou success:moveSuccess failure:^(NSError *error) { - NSLog(@"[RecentsDataSource] Failed to mark as direct"); + MXLogDebug(@"[RecentsDataSource] Failed to mark as direct"); if (moveFailure) { @@ -1650,14 +1650,14 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou NSString* tagOrder = [room.mxSession tagOrderToBeAtIndex:newPath.row from:oldPos withTag:dstRoomTag]; - NSLog(@"[RecentsDataSource] Update the room %@ [%@] tag from %@ to %@ with tag order %@", room.roomId, room.summary.displayname, oldRoomTag, dstRoomTag, tagOrder); + MXLogDebug(@"[RecentsDataSource] Update the room %@ [%@] tag from %@ to %@ with tag order %@", room.roomId, room.summary.displayname, oldRoomTag, dstRoomTag, tagOrder); [room replaceTag:oldRoomTag byTag:dstRoomTag withOrder:tagOrder success: ^{ - NSLog(@"[RecentsDataSource] move is done"); + MXLogDebug(@"[RecentsDataSource] move is done"); if (moveSuccess) { @@ -1668,7 +1668,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou } failure:^(NSError *error) { - NSLog(@"[RecentsDataSource] Failed to update the tag %@ of room (%@)", dstRoomTag, room.roomId); + MXLogDebug(@"[RecentsDataSource] Failed to update the tag %@ of room (%@)", dstRoomTag, room.roomId); if (moveFailure) { @@ -1684,7 +1684,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou } else { - NSLog(@"[RecentsDataSource] cannot move this cell"); + MXLogDebug(@"[RecentsDataSource] cannot move this cell"); if (moveFailure) { diff --git a/Riot/Modules/Common/Recents/RecentsViewController.m b/Riot/Modules/Common/Recents/RecentsViewController.m index e510c5227..d559f64d0 100644 --- a/Riot/Modules/Common/Recents/RecentsViewController.m +++ b/Riot/Modules/Common/Recents/RecentsViewController.m @@ -469,7 +469,7 @@ } } failure:^(NSError * _Nonnull error) { - NSLog(@"[RecentsViewController] Failed to join an invited room (%@)", room.roomId); + MXLogDebug(@"[RecentsViewController] Failed to join an invited room (%@)", room.roomId); [self presentRoomJoinFailedAlertForError:error completion:^{ if (completion) { @@ -491,7 +491,7 @@ completion(YES); } } failure:^(NSError * _Nonnull error) { - NSLog(@"[RecentsViewController] Failed to reject an invited room (%@)", room.roomId); + MXLogDebug(@"[RecentsViewController] Failed to reject an invited room (%@)", room.roomId); [[AppDelegate theDelegate] showErrorAsAlert:error]; if (completion) @@ -1171,7 +1171,7 @@ // TODO GFO cancel pending uploads related to this room - NSLog(@"[RecentsViewController] Leave room (%@)", room.roomId); + MXLogDebug(@"[RecentsViewController] Leave room (%@)", room.roomId); [room leave:^{ @@ -1185,7 +1185,7 @@ } failure:^(NSError *error) { - NSLog(@"[RecentsViewController] Failed to leave room"); + MXLogDebug(@"[RecentsViewController] Failed to leave room"); if (weakSelf) { typeof(self) self = weakSelf; @@ -1274,7 +1274,7 @@ typeof(self) self = weakSelf; [self stopActivityIndicator]; - NSLog(@"[RecentsViewController] Failed to update direct tag of the room (%@)", editedRoomId); + MXLogDebug(@"[RecentsViewController] Failed to update direct tag of the room (%@)", editedRoomId); // Notify the end user NSString *userId = self.mainSession.myUser.userId; // TODO: handle multi-account @@ -1835,7 +1835,7 @@ { if (!self.self.mainSession) { - NSLog(@"[RecentsViewController] Fail to show room directory, session is nil"); + MXLogDebug(@"[RecentsViewController] Fail to show room directory, session is nil"); return; } @@ -1855,7 +1855,7 @@ { if (!self.recentsDataSource) { - NSLog(@"[RecentsViewController] Fail to open public room, dataSource is not kind of class MXKRecentsDataSource"); + MXLogDebug(@"[RecentsViewController] Fail to open public room, dataSource is not kind of class MXKRecentsDataSource"); return; } diff --git a/Riot/Modules/Communities/Home/GroupHomeViewController.m b/Riot/Modules/Communities/Home/GroupHomeViewController.m index a9f939bf6..a76f0096c 100644 --- a/Riot/Modules/Communities/Home/GroupHomeViewController.m +++ b/Riot/Modules/Communities/Home/GroupHomeViewController.m @@ -213,19 +213,19 @@ // Trigger a refresh on the group summary. [self.mxSession updateGroupSummary:_group success:(isPreview ? success : nil) failure:^(NSError *error) { - NSLog(@"[GroupHomeViewController] viewWillAppear: group summary update failed %@", _group.groupId); + MXLogDebug(@"[GroupHomeViewController] viewWillAppear: group summary update failed %@", _group.groupId); }]; // Trigger a refresh on the group members (ignore here the invited users). [self.mxSession updateGroupUsers:_group success:(isPreview ? success : nil) failure:^(NSError *error) { - NSLog(@"[GroupHomeViewController] viewWillAppear: group members update failed %@", _group.groupId); + MXLogDebug(@"[GroupHomeViewController] viewWillAppear: group members update failed %@", _group.groupId); }]; // Trigger a refresh on the group rooms. [self.mxSession updateGroupRooms:_group success:(isPreview ? success : nil) failure:^(NSError *error) { - NSLog(@"[GroupHomeViewController] viewWillAppear: group rooms update failed %@", _group.groupId); + MXLogDebug(@"[GroupHomeViewController] viewWillAppear: group rooms update failed %@", _group.groupId); }]; } @@ -670,7 +670,7 @@ } failure:^(NSError *error) { - NSLog(@"[GroupDetailsViewController] join group (%@) failed", _group.groupId); + MXLogDebug(@"[GroupDetailsViewController] join group (%@) failed", _group.groupId); if (weakSelf) { @@ -703,7 +703,7 @@ } failure:^(NSError *error) { - NSLog(@"[GroupDetailsViewController] leave group (%@) failed", _group.groupId); + MXLogDebug(@"[GroupDetailsViewController] leave group (%@) failed", _group.groupId); if (weakSelf) { @@ -857,7 +857,7 @@ } } failure:^(NSError *error) { - NSLog(@"[GroupHomeViewController] Error: The homeserver failed to resolve the room alias (%@)", roomIdOrAlias); + MXLogDebug(@"[GroupHomeViewController] Error: The homeserver failed to resolve the room alias (%@)", roomIdOrAlias); }]; } } diff --git a/Riot/Modules/Communities/Members/GroupParticipantsViewController.m b/Riot/Modules/Communities/Members/GroupParticipantsViewController.m index f0bddf1e0..7d572e363 100644 --- a/Riot/Modules/Communities/Members/GroupParticipantsViewController.m +++ b/Riot/Modules/Communities/Members/GroupParticipantsViewController.m @@ -248,12 +248,12 @@ // Trigger a refresh on the group members and the invited users. [self.mxSession updateGroupUsers:_group success:(isPreview ? success : nil) failure:^(NSError *error) { - NSLog(@"[GroupParticipantsViewController] viewWillAppear: group members update failed %@", _group.groupId); + MXLogDebug(@"[GroupParticipantsViewController] viewWillAppear: group members update failed %@", _group.groupId); }]; [self.mxSession updateGroupInvitedUsers:_group success:(isPreview ? success : nil) failure:^(NSError *error) { - NSLog(@"[GroupParticipantsViewController] viewWillAppear: invited users update failed %@", _group.groupId); + MXLogDebug(@"[GroupParticipantsViewController] viewWillAppear: invited users update failed %@", _group.groupId); }]; } @@ -1085,7 +1085,7 @@ } failure:^(NSError *error) { [self removePendingActionMask]; - NSLog(@"[GroupParticipantsVC] Leave group %@ failed", _group.groupId); + MXLogDebug(@"[GroupParticipantsVC] Leave group %@ failed", _group.groupId); // Alert user [[AppDelegate theDelegate] showErrorAsAlert:error]; @@ -1128,7 +1128,7 @@ typeof(self) self = weakSelf; self->currentAlert = nil; - NSLog(@"[GroupParticipantsVC] Kick %@ failed", memberUserId); + MXLogDebug(@"[GroupParticipantsVC] Kick %@ failed", memberUserId); // Alert user [[AppDelegate theDelegate] showErrorAsAlert:[NSError errorWithDomain:@"GroupDomain" code:0 userInfo:@{NSLocalizedDescriptionKey:[NSBundle mxk_localizedStringForKey:@"not_supported_yet"]}]]; } @@ -1187,7 +1187,7 @@ { participantId = identifiers.firstObject; - NSLog(@"[GroupParticipantsVC] Invite %@ failed", participantId); + MXLogDebug(@"[GroupParticipantsVC] Invite %@ failed", participantId); [[AppDelegate theDelegate] showErrorAsAlert:[NSError errorWithDomain:@"GroupDomain" code:0 userInfo:@{NSLocalizedDescriptionKey:[NSBundle mxk_localizedStringForKey:@"not_supported_yet"]}]]; } } diff --git a/Riot/Modules/Communities/Rooms/GroupRoomsViewController.m b/Riot/Modules/Communities/Rooms/GroupRoomsViewController.m index 5dd236dda..aece49992 100644 --- a/Riot/Modules/Communities/Rooms/GroupRoomsViewController.m +++ b/Riot/Modules/Communities/Rooms/GroupRoomsViewController.m @@ -212,7 +212,7 @@ // Trigger a refresh on the group rooms. [self.mxSession updateGroupRooms:_group success:(isPreview ? success : nil) failure:^(NSError *error) { - NSLog(@"[GroupRoomsViewController] viewWillAppear: group rooms update failed %@", _group.groupId); + MXLogDebug(@"[GroupRoomsViewController] viewWillAppear: group rooms update failed %@", _group.groupId); }]; } diff --git a/Riot/Modules/Contacts/DataSources/ContactsDataSource.m b/Riot/Modules/Contacts/DataSources/ContactsDataSource.m index dea3437ff..cace7ca50 100644 --- a/Riot/Modules/Contacts/DataSources/ContactsDataSource.m +++ b/Riot/Modules/Contacts/DataSources/ContactsDataSource.m @@ -221,7 +221,7 @@ if ((![error.domain isEqualToString:NSURLErrorDomain] || error.code != NSURLErrorCancelled)) { // But for other errors, launch a local search - NSLog(@"[ContactsDataSource] [MXRestClient searchUsers] returns an error. Do a search on local known contacts"); + MXLogDebug(@"[ContactsDataSource] [MXRestClient searchUsers] returns an error. Do a search on local known contacts"); [self searchWithPattern:searchText forceReset:forceRefresh hsUserDirectory:NO]; } }]; diff --git a/Riot/Modules/Contacts/Details/ContactDetailsViewController.m b/Riot/Modules/Contacts/Details/ContactDetailsViewController.m index 3823a1f77..f8289e35a 100644 --- a/Riot/Modules/Contacts/Details/ContactDetailsViewController.m +++ b/Riot/Modules/Contacts/Details/ContactDetailsViewController.m @@ -890,7 +890,7 @@ } failure:^(NSError *error) { [self removePendingActionMask]; - NSLog(@"[ContactDetailsViewController] Ignore %@ failed", self.firstMatrixId); + MXLogDebug(@"[ContactDetailsViewController] Ignore %@ failed", self.firstMatrixId); // Notify MatrixKit user [[AppDelegate theDelegate] showErrorAsAlert:error]; @@ -931,7 +931,7 @@ __strong __typeof(weakSelf)self = weakSelf; [self removePendingActionMask]; - NSLog(@"[ContactDetailsViewController] Unignore %@ failed", self.firstMatrixId); + MXLogDebug(@"[ContactDetailsViewController] Unignore %@ failed", self.firstMatrixId); // Notify MatrixKit user [[AppDelegate theDelegate] showErrorAsAlert:error]; @@ -1010,7 +1010,7 @@ void (^onFailure)(NSError *) = ^(NSError *error){ MXStrongifyAndReturnIfNil(self); - NSLog(@"[ContactDetailsViewController] Create room failed"); + MXLogDebug(@"[ContactDetailsViewController] Create room failed"); self->roomCreationRequest = nil; @@ -1086,7 +1086,7 @@ } failure:^(NSError *error) { - NSLog(@"[ContactDetailsViewController] Create room failed"); + MXLogDebug(@"[ContactDetailsViewController] Create room failed"); roomCreationRequest = nil; diff --git a/Riot/Modules/GDPR/GDPRConsentViewController.swift b/Riot/Modules/GDPR/GDPRConsentViewController.swift index 0723326a1..29ebdc22c 100644 --- a/Riot/Modules/GDPR/GDPRConsentViewController.swift +++ b/Riot/Modules/GDPR/GDPRConsentViewController.swift @@ -46,7 +46,7 @@ final public class GDPRConsentViewController: WebViewViewController { // When navigation finish on path `consentSuccessURLPath` with no query, it means that user consent to GDPR if let url = webView.url, url.path == GDPRConsentViewController.consentSuccessURLPath, url.query == nil { - NSLog("[GDPRConsentViewController] User consent to GDPR") + MXLog.debug("[GDPRConsentViewController] User consent to GDPR") self.delegate?.gdprConsentViewControllerDidConsentToGDPRWithSuccess(self) } } diff --git a/Riot/Modules/Home/Fallback/AuthFallBackViewController.m b/Riot/Modules/Home/Fallback/AuthFallBackViewController.m index ccad5b671..8d0e84e14 100644 --- a/Riot/Modules/Home/Fallback/AuthFallBackViewController.m +++ b/Riot/Modules/Home/Fallback/AuthFallBackViewController.m @@ -83,7 +83,7 @@ NSString *FallBackViewControllerJavascriptOnLogin = @"window.matrixLogin.onLogin forDataRecords:@[record] completionHandler:^ { - NSLog(@"[AuthFallBackViewController] clearCookies: Cookies for %@ deleted successfully", record.displayName); + MXLogDebug(@"[AuthFallBackViewController] clearCookies: Cookies for %@ deleted successfully", record.displayName); }]; } }]; diff --git a/Riot/Modules/Integrations/IntegrationManagerViewController.m b/Riot/Modules/Integrations/IntegrationManagerViewController.m index 71397a958..e4b48d09c 100644 --- a/Riot/Modules/Integrations/IntegrationManagerViewController.m +++ b/Riot/Modules/Integrations/IntegrationManagerViewController.m @@ -107,7 +107,7 @@ NSString *const kIntegrationManagerAddIntegrationScreen = @"add_integ"; } failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); - NSLog(@"[IntegraionManagerVS] Cannot open due to missing scalar token. Error: %@", error); + MXLogDebug(@"[IntegraionManagerVS] Cannot open due to missing scalar token. Error: %@", error); self->operation = nil; [self stopActivityIndicator]; @@ -275,7 +275,7 @@ NSString *const kIntegrationManagerAddIntegrationScreen = @"add_integ"; } else { - NSLog(@"[IntegrationManagerViewControllerVC] Unhandled postMessage event with action %@: %@", action, requestData); + MXLogDebug(@"[IntegrationManagerViewControllerVC] Unhandled postMessage event with action %@: %@", action, requestData); } } @@ -298,7 +298,7 @@ NSString *const kIntegrationManagerAddIntegrationScreen = @"add_integ"; - (void)inviteUser:(NSString*)userId request:(NSString*)requestId data:(NSDictionary*)requestData { - NSLog(@"[IntegrationManagerVC] Received request to invite %@ into room %@.", userId, roomId); + MXLogDebug(@"[IntegrationManagerVC] Received request to invite %@ into room %@.", userId, roomId); [self roomCheckForRequest:requestId data:requestData onComplete:^(MXRoom *room, MXRoomState *roomState) { @@ -332,7 +332,7 @@ NSString *const kIntegrationManagerAddIntegrationScreen = @"add_integ"; - (void)setWidget:(NSString*)requestId data:(NSDictionary*)requestData { - NSLog(@"[IntegrationManagerVC] Received request to set widget"); + MXLogDebug(@"[IntegrationManagerVC] Received request to set widget"); NSString *widget_id, *widgetType, *widgetUrl; NSString *widgetName; // optional @@ -525,7 +525,7 @@ NSString *const kIntegrationManagerAddIntegrationScreen = @"add_integ"; - (void)getMembershipState:(NSString*)userId request:(NSString*)requestId data:(NSDictionary*)requestData { - NSLog(@"[IntegrationManagerVC] membership_state of %@ in room %@ requested.", userId, roomId); + MXLogDebug(@"[IntegrationManagerVC] membership_state of %@ in room %@ requested.", userId, roomId); [self roomCheckForRequest:requestId data:requestData onComplete:^(MXRoom *room, MXRoomState *roomState) { MXRoomMember *member = [roomState.members memberWithUserId:userId]; @@ -535,7 +535,7 @@ NSString *const kIntegrationManagerAddIntegrationScreen = @"add_integ"; - (void)getJoinRules:(NSString*)requestId data:(NSDictionary*)requestData { - NSLog(@"[IntegrationManagerVC] join_rules of %@ requested.", roomId); + MXLogDebug(@"[IntegrationManagerVC] join_rules of %@ requested.", roomId); [self roomCheckForRequest:requestId data:requestData onComplete:^(MXRoom *room, MXRoomState *roomState) { MXEvent *event = [roomState stateEventsWithType:kMXEventTypeStringRoomJoinRules].lastObject; @@ -545,7 +545,7 @@ NSString *const kIntegrationManagerAddIntegrationScreen = @"add_integ"; - (void)setPlumbingState:(NSString*)requestId data:(NSDictionary*)requestData { - NSLog(@"[IntegrationManagerVC] Received request to set plumbing state to status %@ in room %@.", requestData[@"status"], roomId); + MXLogDebug(@"[IntegrationManagerVC] Received request to set plumbing state to status %@ in room %@.", requestData[@"status"], roomId); [self roomCheckForRequest:requestId data:requestData onComplete:^(MXRoom *room, MXRoomState *roomState) { NSString *status; @@ -582,7 +582,7 @@ NSString *const kIntegrationManagerAddIntegrationScreen = @"add_integ"; } else { - NSLog(@"[IntegrationManagerVC] setPlumbingState. Error: Plumbing state status should be a string."); + MXLogDebug(@"[IntegrationManagerVC] setPlumbingState. Error: Plumbing state status should be a string."); } }]; @@ -590,7 +590,7 @@ NSString *const kIntegrationManagerAddIntegrationScreen = @"add_integ"; - (void)getBotOptions:(NSString*)userId request:(NSString*)requestId data:(NSDictionary*)requestData { - NSLog(@"[IntegrationManagerVC] Received request to get options for bot %@ in room %@", userId, roomId); + MXLogDebug(@"[IntegrationManagerVC] Received request to get options for bot %@ in room %@", userId, roomId); [self roomCheckForRequest:requestId data:requestData onComplete:^(MXRoom *room, MXRoomState *roomState) { NSString *stateKey = [NSString stringWithFormat:@"_%@", userId]; @@ -617,7 +617,7 @@ NSString *const kIntegrationManagerAddIntegrationScreen = @"add_integ"; - (void)setBotOptions:(NSString*)userId request:(NSString*)requestId data:(NSDictionary*)requestData { - NSLog(@"[IntegrationManagerVC] Received request to set options for bot %@ in room %@", userId, roomId); + MXLogDebug(@"[IntegrationManagerVC] Received request to set options for bot %@ in room %@", userId, roomId); [self roomCheckForRequest:requestId data:requestData onComplete:^(MXRoom *room, MXRoomState *roomState) { NSDictionary *content; @@ -654,14 +654,14 @@ NSString *const kIntegrationManagerAddIntegrationScreen = @"add_integ"; } else { - NSLog(@"[IntegrationManagerVC] setBotOptions. Error: options should be a dict."); + MXLogDebug(@"[IntegrationManagerVC] setBotOptions. Error: options should be a dict."); } }]; } - (void)setBotPower:(NSString*)userId request:(NSString*)requestId data:(NSDictionary*)requestData { - NSLog(@"[IntegrationManagerVC] Received request to set power level to %@ for bot %@ in room %@.", requestData[@"level"], userId, roomId); + MXLogDebug(@"[IntegrationManagerVC] Received request to set power level to %@ for bot %@ in room %@.", requestData[@"level"], userId, roomId); [self roomCheckForRequest:requestId data:requestData onComplete:^(MXRoom *room, MXRoomState *roomState) { NSInteger level = -1; @@ -693,7 +693,7 @@ NSString *const kIntegrationManagerAddIntegrationScreen = @"add_integ"; } else { - NSLog(@"[IntegrationManagerVC] setBotPower. Power level must be positive integer."); + MXLogDebug(@"[IntegrationManagerVC] setBotPower. Power level must be positive integer."); [self sendLocalisedError:@"widget_integration_positive_power_level" toRequest:requestId]; } }]; @@ -741,7 +741,7 @@ NSString *const kIntegrationManagerAddIntegrationScreen = @"add_integ"; { WidgetManagerConfig *config = [[WidgetManager sharedManager] configForUser:mxSession.myUser.userId]; - NSLog(@"[IntegrationManagerVC] presentTerms for %@", config.baseUrl); + MXLogDebug(@"[IntegrationManagerVC] presentTerms for %@", config.baseUrl); ServiceTermsModalCoordinatorBridgePresenter *serviceTermsModalCoordinatorBridgePresenter = [[ServiceTermsModalCoordinatorBridgePresenter alloc] initWithSession:mxSession baseUrl:config.baseUrl serviceType:MXServiceTypeIntegrationManager diff --git a/Riot/Modules/Integrations/WidgetPicker/WidgetPickerViewController.m b/Riot/Modules/Integrations/WidgetPicker/WidgetPickerViewController.m index ad4e35e82..32bb833a0 100644 --- a/Riot/Modules/Integrations/WidgetPicker/WidgetPickerViewController.m +++ b/Riot/Modules/Integrations/WidgetPicker/WidgetPickerViewController.m @@ -121,7 +121,7 @@ } failure:^(NSError * _Nonnull error) { - NSLog(@"[WidgetPickerVC] Get widget URL failed with error: %@", error); + MXLogDebug(@"[WidgetPickerVC] Get widget URL failed with error: %@", error); if (canPresentServiceTerms && [error.domain isEqualToString:WidgetManagerErrorDomain] @@ -147,7 +147,7 @@ WidgetManagerConfig *config = [[WidgetManager sharedManager] configForUser:widget.mxSession.myUser.userId]; - NSLog(@"[WidgetVC] presentTerms for %@", config.baseUrl); + MXLogDebug(@"[WidgetVC] presentTerms for %@", config.baseUrl); ServiceTermsModalCoordinatorBridgePresenter *serviceTermsModalCoordinatorBridgePresenter = [[ServiceTermsModalCoordinatorBridgePresenter alloc] initWithSession:widget.mxSession baseUrl:config.baseUrl serviceType:MXServiceTypeIntegrationManager diff --git a/Riot/Modules/Integrations/Widgets/Jitsi/JitsiService.swift b/Riot/Modules/Integrations/Widgets/Jitsi/JitsiService.swift index ffc884ced..4820d138b 100644 --- a/Riot/Modules/Integrations/Widgets/Jitsi/JitsiService.swift +++ b/Riot/Modules/Integrations/Widgets/Jitsi/JitsiService.swift @@ -151,7 +151,7 @@ final class JitsiService: NSObject { authType = jitsiWellKnown.authenticationType continueOperation = true case .failure(let error): - NSLog("[JitsiService] Fail to get Jitsi Well Known with error: \(error)") + MXLog.debug("[JitsiService] Fail to get Jitsi Well Known with error: \(error)") if let error = error as? JitsiServiceError, error == .noWellKnown { // no well-known, continue with no auth continueOperation = true @@ -251,7 +251,7 @@ final class JitsiService: NSObject { roomID: String, isAudioOnly: Bool) -> [String: Any]? { guard MXTools.isMatrixRoomIdentifier(roomID) else { - NSLog("[JitsiService] createJitsiWidgetContent the roomID is not valid") + MXLog.debug("[JitsiService] createJitsiWidgetContent the roomID is not valid") return nil } diff --git a/Riot/Modules/Integrations/Widgets/Jitsi/JitsiViewController.m b/Riot/Modules/Integrations/Widgets/Jitsi/JitsiViewController.m index 29d528350..393f757ab 100644 --- a/Riot/Modules/Integrations/Widgets/Jitsi/JitsiViewController.m +++ b/Riot/Modules/Integrations/Widgets/Jitsi/JitsiViewController.m @@ -125,7 +125,7 @@ static NSString * _Nonnull kJitsiFeatureFlagChatEnabled = @"chat.enabled"; } else { - NSLog(@"[JitsiVC] Failed to load widget: %@. Widget event: %@", widget, widget.widgetEvent); + MXLogDebug(@"[JitsiVC] Failed to load widget: %@. Widget event: %@", widget, widget.widgetEvent); if (failure) { @@ -162,7 +162,7 @@ static NSString * _Nonnull kJitsiFeatureFlagChatEnabled = @"chat.enabled"; } } failure:^(NSError * _Nonnull error) { - NSLog(@"[JitsiVC] Failed to load widget 2: %@. Widget event: %@", widget, widget.widgetEvent); + MXLogDebug(@"[JitsiVC] Failed to load widget 2: %@. Widget event: %@", widget, widget.widgetEvent); if (failure) { @@ -316,7 +316,7 @@ static NSString * _Nonnull kJitsiFeatureFlagChatEnabled = @"chat.enabled"; { if (data[kJitsiDataErrorKey] != nil) { - NSLog(@"[JitsiViewController] conferenceTerminated - data: %@", data); + MXLogDebug(@"[JitsiViewController] conferenceTerminated - data: %@", data); } else { diff --git a/Riot/Modules/Integrations/Widgets/WidgetViewController.m b/Riot/Modules/Integrations/Widgets/WidgetViewController.m index c299243cb..9eb26718f 100644 --- a/Riot/Modules/Integrations/Widgets/WidgetViewController.m +++ b/Riot/Modules/Integrations/Widgets/WidgetViewController.m @@ -125,7 +125,7 @@ NSString *const kJavascriptSendResponseToPostMessageAPI = @"riotIOS.sendResponse { [widgetManager closeWidget:widgetId inRoom:room success:^{ } failure:^(NSError *error) { - NSLog(@"[WidgetVC] removeCurrentWidget failed. Error: %@", error); + MXLogDebug(@"[WidgetVC] removeCurrentWidget failed. Error: %@", error); }]; } } @@ -202,7 +202,7 @@ NSString *const kJavascriptSendResponseToPostMessageAPI = @"riotIOS.sendResponse } failure:^(NSError * _Nullable error) { - NSLog(@"[WidgetVC] setPermissionForWidget failed. Error: %@", error); + MXLogDebug(@"[WidgetVC] setPermissionForWidget failed. Error: %@", error); sharedSettings = nil; }]; @@ -274,7 +274,7 @@ NSString *const kJavascriptSendResponseToPostMessageAPI = @"riotIOS.sendResponse [sharedSettings setPermission:WidgetPermissionDeclined for:widget success:^{ sharedSettings = nil; } failure:^(NSError * _Nullable error) { - NSLog(@"[WidgetVC] revokePermissionForCurrentWidget failed. Error: %@", error); + MXLogDebug(@"[WidgetVC] revokePermissionForCurrentWidget failed. Error: %@", error); sharedSettings = nil; }]; } @@ -401,7 +401,7 @@ NSString *const kJavascriptSendResponseToPostMessageAPI = @"riotIOS.sendResponse } else { - NSLog(@"[WidgetVC] shouldStartLoadWithRequest: ERROR: Missing request id in postMessage API %@", parameters); + MXLogDebug(@"[WidgetVC] shouldStartLoadWithRequest: ERROR: Missing request id in postMessage API %@", parameters); } } @@ -417,7 +417,7 @@ NSString *const kJavascriptSendResponseToPostMessageAPI = @"riotIOS.sendResponse [[UIApplication sharedApplication] vc_open:linkURL completionHandler:^(BOOL success) { if (!success) { - NSLog(@"[WidgetVC] webView:decidePolicyForNavigationAction:decisionHandler fail to open external link: %@", linkURL); + MXLogDebug(@"[WidgetVC] webView:decidePolicyForNavigationAction:decisionHandler fail to open external link: %@", linkURL); } }]; decisionHandler(WKNavigationActionPolicyCancel); @@ -433,7 +433,7 @@ NSString *const kJavascriptSendResponseToPostMessageAPI = @"riotIOS.sendResponse NSString *errorDescription = error.description; errorDescription = [self stringByReplacingScalarTokenInString:errorDescription byScalarToken:@"..."]; - NSLog(@"[WidgetVC] didFailLoadWithError: %@", errorDescription); + MXLogDebug(@"[WidgetVC] didFailLoadWithError: %@", errorDescription); [self stopActivityIndicator]; [self showErrorAsAlert:error]; @@ -446,7 +446,7 @@ NSString *const kJavascriptSendResponseToPostMessageAPI = @"riotIOS.sendResponse NSHTTPURLResponse * response = (NSHTTPURLResponse *)navigationResponse.response; if (response.statusCode != 200) { - NSLog(@"[WidgetVC] decidePolicyForNavigationResponse: statusCode: %@", @(response.statusCode)); + MXLogDebug(@"[WidgetVC] decidePolicyForNavigationResponse: statusCode: %@", @(response.statusCode)); } if (response.statusCode == 403 && [[WidgetManager sharedManager] isScalarUrl:self.URL forUser:self.widget.mxSession.myUser.userId]) @@ -485,7 +485,7 @@ NSString *const kJavascriptSendResponseToPostMessageAPI = @"riotIOS.sendResponse } else { - NSLog(@"[WidgetVC] onPostMessageRequest: ERROR: Invalid content for m.sticker: %@", requestData); + MXLogDebug(@"[WidgetVC] onPostMessageRequest: ERROR: Invalid content for m.sticker: %@", requestData); } // Consider we are done with the sticker picker widget @@ -515,12 +515,12 @@ NSString *const kJavascriptSendResponseToPostMessageAPI = @"riotIOS.sendResponse } else { - NSLog(@"[WidgetVC] onPostMessageRequest: ERROR: Invalid content for integration_manager_open: %@", requestData); + MXLogDebug(@"[WidgetVC] onPostMessageRequest: ERROR: Invalid content for integration_manager_open: %@", requestData); } } else { - NSLog(@"[WidgetVC] onPostMessageRequest: ERROR: Unsupported action: %@: %@", action, requestData); + MXLogDebug(@"[WidgetVC] onPostMessageRequest: ERROR: Unsupported action: %@: %@", action, requestData); } } @@ -571,7 +571,7 @@ NSString *const kJavascriptSendResponseToPostMessageAPI = @"riotIOS.sendResponse - (void)sendError:(NSString*)message toRequest:(NSString*)requestId { - NSLog(@"[WidgetVC] sendError: Action %@ failed with message: %@", requestId, message); + MXLogDebug(@"[WidgetVC] sendError: Action %@ failed with message: %@", requestId, message); // TODO: JS has an additional optional parameter: nestedError [self sendNSObjectResponse:@{ @@ -610,7 +610,7 @@ NSString *const kJavascriptSendResponseToPostMessageAPI = @"riotIOS.sendResponse */ - (void)fixScalarToken { - NSLog(@"[WidgetVC] fixScalarToken"); + MXLogDebug(@"[WidgetVC] fixScalarToken"); self->webView.hidden = YES; @@ -621,11 +621,11 @@ NSString *const kJavascriptSendResponseToPostMessageAPI = @"riotIOS.sendResponse [WidgetManager.sharedManager getScalarTokenForMXSession:widget.mxSession validate:NO success:^(NSString *scalarToken) { MXStrongifyAndReturnIfNil(self); - NSLog(@"[WidgetVC] fixScalarToken: DONE"); + MXLogDebug(@"[WidgetVC] fixScalarToken: DONE"); [self loadDataWithScalarToken:scalarToken]; } failure:^(NSError *error) { - NSLog(@"[WidgetVC] fixScalarToken: Error: %@", error); + MXLogDebug(@"[WidgetVC] fixScalarToken: Error: %@", error); if ([error.domain isEqualToString:WidgetManagerErrorDomain] && error.code == WidgetManagerErrorCodeTermsNotSigned) @@ -659,7 +659,7 @@ NSString *const kJavascriptSendResponseToPostMessageAPI = @"riotIOS.sendResponse WidgetManagerConfig *config = [[WidgetManager sharedManager] configForUser:widget.mxSession.myUser.userId]; - NSLog(@"[WidgetVC] presentTerms for %@", config.baseUrl); + MXLogDebug(@"[WidgetVC] presentTerms for %@", config.baseUrl); ServiceTermsModalCoordinatorBridgePresenter *serviceTermsModalCoordinatorBridgePresenter = [[ServiceTermsModalCoordinatorBridgePresenter alloc] initWithSession:widget.mxSession baseUrl:config.baseUrl serviceType:MXServiceTypeIntegrationManager diff --git a/Riot/Modules/KeyBackup/Recover/KeyBackupRecoverCoordinatorBridgePresenter.swift b/Riot/Modules/KeyBackup/Recover/KeyBackupRecoverCoordinatorBridgePresenter.swift index 9b6fdc8f9..f1d98baa0 100644 --- a/Riot/Modules/KeyBackup/Recover/KeyBackupRecoverCoordinatorBridgePresenter.swift +++ b/Riot/Modules/KeyBackup/Recover/KeyBackupRecoverCoordinatorBridgePresenter.swift @@ -59,7 +59,7 @@ final class KeyBackupRecoverCoordinatorBridgePresenter: NSObject { func push(from navigationController: UINavigationController, animated: Bool) { - NSLog("[KeyBackupRecoverCoordinatorBridgePresenter] Push complete security from \(navigationController)") + MXLog.debug("[KeyBackupRecoverCoordinatorBridgePresenter] Push complete security from \(navigationController)") let navigationRouter = NavigationRouter(navigationController: navigationController) diff --git a/Riot/Modules/KeyBackup/Recover/RecoveryKey/KeyBackupRecoverFromRecoveryKeyViewController.swift b/Riot/Modules/KeyBackup/Recover/RecoveryKey/KeyBackupRecoverFromRecoveryKeyViewController.swift index 4b2bc5356..c332397b4 100644 --- a/Riot/Modules/KeyBackup/Recover/RecoveryKey/KeyBackupRecoverFromRecoveryKeyViewController.swift +++ b/Riot/Modules/KeyBackup/Recover/RecoveryKey/KeyBackupRecoverFromRecoveryKeyViewController.swift @@ -215,7 +215,7 @@ final class KeyBackupRecoverFromRecoveryKeyViewController: UIViewController { do { documentContent = try String(contentsOf: documentURL) } catch { - print("Error: \(error)") + MXLog.debug("Error: \(error)") documentContent = nil } diff --git a/Riot/Modules/KeyVerification/Common/KeyVerificationCoordinator.swift b/Riot/Modules/KeyVerification/Common/KeyVerificationCoordinator.swift index aa92f2749..19dbc98f8 100644 --- a/Riot/Modules/KeyVerification/Common/KeyVerificationCoordinator.swift +++ b/Riot/Modules/KeyVerification/Common/KeyVerificationCoordinator.swift @@ -168,7 +168,7 @@ final class KeyVerificationCoordinator: KeyVerificationCoordinatorType { // In the case of the complete security flow, come back to the root screen if any child flow // like device verification has been cancelled if self.completeSecurityCoordinator != nil && childCoordinators.count > 1 { - NSLog("[KeyVerificationCoordinator] didCancel: popToRootModule") + MXLog.debug("[KeyVerificationCoordinator] didCancel: popToRootModule") self.navigationRouter.popToRootModule(animated: true) return } @@ -307,7 +307,7 @@ extension KeyVerificationCoordinator: KeyVerificationDataLoadingCoordinatorDeleg if let sasTransaction = transaction as? MXSASTransaction { self.showVerifyBySAS(transaction: sasTransaction, animated: true) } else { - NSLog("[KeyVerificationCoordinator] Transaction \(transaction) is not supported") + MXLog.debug("[KeyVerificationCoordinator] Transaction \(transaction) is not supported") self.didCancel() } } diff --git a/Riot/Modules/KeyVerification/Common/KeyVerificationCoordinatorBridgePresenter.swift b/Riot/Modules/KeyVerification/Common/KeyVerificationCoordinatorBridgePresenter.swift index 52e7e932e..d9d4a20c1 100644 --- a/Riot/Modules/KeyVerification/Common/KeyVerificationCoordinatorBridgePresenter.swift +++ b/Riot/Modules/KeyVerification/Common/KeyVerificationCoordinatorBridgePresenter.swift @@ -59,7 +59,7 @@ final class KeyVerificationCoordinatorBridgePresenter: NSObject { func present(from viewController: UIViewController, otherUserId: String, otherDeviceId: String, animated: Bool) { - NSLog("[KeyVerificationCoordinatorBridgePresenter] Present from \(viewController)") + MXLog.debug("[KeyVerificationCoordinatorBridgePresenter] Present from \(viewController)") let keyVerificationCoordinator = KeyVerificationCoordinator(session: self.session, flow: .verifyDevice(userId: otherUserId, deviceId: otherDeviceId)) self.present(coordinator: keyVerificationCoordinator, from: viewController, animated: animated) @@ -67,7 +67,7 @@ final class KeyVerificationCoordinatorBridgePresenter: NSObject { func present(from viewController: UIViewController, roomMember: MXRoomMember, animated: Bool) { - NSLog("[KeyVerificationCoordinatorBridgePresenter] Present from \(viewController)") + MXLog.debug("[KeyVerificationCoordinatorBridgePresenter] Present from \(viewController)") let keyVerificationCoordinator = KeyVerificationCoordinator(session: self.session, flow: .verifyUser(roomMember)) self.present(coordinator: keyVerificationCoordinator, from: viewController, animated: animated) @@ -75,7 +75,7 @@ final class KeyVerificationCoordinatorBridgePresenter: NSObject { func present(from viewController: UIViewController, incomingTransaction: MXIncomingSASTransaction, animated: Bool) { - NSLog("[KeyVerificationCoordinatorBridgePresenter] Present incoming verification from \(viewController)") + MXLog.debug("[KeyVerificationCoordinatorBridgePresenter] Present incoming verification from \(viewController)") let keyVerificationCoordinator = KeyVerificationCoordinator(session: self.session, flow: .incomingSASTransaction(incomingTransaction)) self.present(coordinator: keyVerificationCoordinator, from: viewController, animated: animated) @@ -83,7 +83,7 @@ final class KeyVerificationCoordinatorBridgePresenter: NSObject { func present(from viewController: UIViewController, incomingKeyVerificationRequest: MXKeyVerificationRequest, animated: Bool) { - NSLog("[KeyVerificationCoordinatorBridgePresenter] Present incoming key verification request from \(viewController)") + MXLog.debug("[KeyVerificationCoordinatorBridgePresenter] Present incoming key verification request from \(viewController)") let keyVerificationCoordinator = KeyVerificationCoordinator(session: self.session, flow: .incomingRequest(incomingKeyVerificationRequest)) self.present(coordinator: keyVerificationCoordinator, from: viewController, animated: animated) @@ -91,7 +91,7 @@ final class KeyVerificationCoordinatorBridgePresenter: NSObject { func presentCompleteSecurity(from viewController: UIViewController, isNewSignIn: Bool, animated: Bool) { - NSLog("[KeyVerificationCoordinatorBridgePresenter] Present complete security from \(viewController)") + MXLog.debug("[KeyVerificationCoordinatorBridgePresenter] Present complete security from \(viewController)") let keyVerificationCoordinator = KeyVerificationCoordinator(session: self.session, flow: .completeSecurity(isNewSignIn)) self.present(coordinator: keyVerificationCoordinator, from: viewController, animated: animated) @@ -99,7 +99,7 @@ final class KeyVerificationCoordinatorBridgePresenter: NSObject { func pushCompleteSecurity(from navigationController: UINavigationController, isNewSignIn: Bool, animated: Bool) { - NSLog("[KeyVerificationCoordinatorBridgePresenter] Push complete security from \(navigationController)") + MXLog.debug("[KeyVerificationCoordinatorBridgePresenter] Push complete security from \(navigationController)") let navigationRouter = NavigationRouter(navigationController: navigationController) @@ -115,7 +115,7 @@ final class KeyVerificationCoordinatorBridgePresenter: NSObject { return } - NSLog("[KeyVerificationCoordinatorBridgePresenter] Dismiss") + MXLog.debug("[KeyVerificationCoordinatorBridgePresenter] Dismiss") coordinator.toPresentable().dismiss(animated: animated) { self.coordinator = nil diff --git a/Riot/Modules/KeyVerification/Common/Loading/KeyVerificationDataLoadingViewModel.swift b/Riot/Modules/KeyVerification/Common/Loading/KeyVerificationDataLoadingViewModel.swift index 6992faf68..b2874db8f 100644 --- a/Riot/Modules/KeyVerification/Common/Loading/KeyVerificationDataLoadingViewModel.swift +++ b/Riot/Modules/KeyVerification/Common/Loading/KeyVerificationDataLoadingViewModel.swift @@ -112,7 +112,7 @@ final class KeyVerificationDataLoadingViewModel: KeyVerificationDataLoadingViewM let otherUserId = self.otherUserId, let otherDeviceId = self.otherDeviceId else { self.update(viewState: .errorMessage(VectorL10n.deviceVerificationErrorCannotLoadDevice)) - NSLog("[KeyVerificationDataLoadingViewModel] Error session.crypto is nil") + MXLog.debug("[KeyVerificationDataLoadingViewModel] Error session.crypto is nil") return } diff --git a/Riot/Modules/KeyVerification/Common/Verify/Scanning/KeyVerificationVerifyByScanningViewModel.swift b/Riot/Modules/KeyVerification/Common/Verify/Scanning/KeyVerificationVerifyByScanningViewModel.swift index 9594946cf..706a121d9 100644 --- a/Riot/Modules/KeyVerification/Common/Verify/Scanning/KeyVerificationVerifyByScanningViewModel.swift +++ b/Riot/Modules/KeyVerification/Common/Verify/Scanning/KeyVerificationVerifyByScanningViewModel.swift @@ -174,7 +174,7 @@ final class KeyVerificationVerifyByScanningViewModel: KeyVerificationVerifyBySca self.removePendingQRCodeTransaction() if keyVerificationTransaction is MXOutgoingSASTransaction == false { - NSLog("[KeyVerificationVerifyByScanningViewModel] SAS transaction should be outgoing") + MXLog.debug("[KeyVerificationVerifyByScanningViewModel] SAS transaction should be outgoing") self.unregisterTransactionDidStateChangeNotification() self.update(viewState: .error(KeyVerificationVerifyByScanningViewModelError.unknown)) } @@ -204,7 +204,7 @@ final class KeyVerificationVerifyByScanningViewModel: KeyVerificationVerifyBySca } guard self.keyVerificationRequest.requestId == transaction.transactionId else { - NSLog("[KeyVerificationVerifyByScanningViewModel] transactionDidStateChange: Not for our transaction (\(self.keyVerificationRequest.requestId)): \(transaction.transactionId)") + MXLog.debug("[KeyVerificationVerifyByScanningViewModel] transactionDidStateChange: Not for our transaction (\(self.keyVerificationRequest.requestId)): \(transaction.transactionId)") return } diff --git a/Riot/Modules/KeyVerification/Device/SelfVerifyWait/KeyVerificationSelfVerifyWaitViewModel.swift b/Riot/Modules/KeyVerification/Device/SelfVerifyWait/KeyVerificationSelfVerifyWaitViewModel.swift index 6da9e3ccf..7188a111e 100644 --- a/Riot/Modules/KeyVerification/Device/SelfVerifyWait/KeyVerificationSelfVerifyWaitViewModel.swift +++ b/Riot/Modules/KeyVerification/Device/SelfVerifyWait/KeyVerificationSelfVerifyWaitViewModel.swift @@ -73,7 +73,7 @@ final class KeyVerificationSelfVerifyWaitViewModel: KeyVerificationSelfVerifyWai private func loadData() { if !self.isNewSignIn { - print("[KeyVerificationSelfVerifyWaitViewModel] loadData: Send a verification request to all devices") + MXLog.debug("[KeyVerificationSelfVerifyWaitViewModel] loadData: Send a verification request to all devices") let keyVerificationService = KeyVerificationService() self.verificationManager.requestVerificationByToDevice(withUserId: self.session.myUserId, deviceIds: nil, methods: keyVerificationService.supportedKeyVerificationMethods(), success: { [weak self] (keyVerificationRequest) in @@ -93,7 +93,7 @@ final class KeyVerificationSelfVerifyWaitViewModel: KeyVerificationSelfVerifyWai if session.state >= MXSessionStateRunning { // Always send request instead of waiting for an incoming one as per recent EW changes - print("[KeyVerificationSelfVerifyWaitViewModel] loadData: Send a verification request to all devices instead of waiting") + MXLog.debug("[KeyVerificationSelfVerifyWaitViewModel] loadData: Send a verification request to all devices instead of waiting") let keyVerificationService = KeyVerificationService() self.verificationManager.requestVerificationByToDevice(withUserId: self.session.myUserId, deviceIds: nil, methods: keyVerificationService.supportedKeyVerificationMethods(), success: { [weak self] (keyVerificationRequest) in diff --git a/Riot/Modules/MajorUpdate/MajorUpdateManager.swift b/Riot/Modules/MajorUpdate/MajorUpdateManager.swift index 373c15f5c..e384e1eef 100644 --- a/Riot/Modules/MajorUpdate/MajorUpdateManager.swift +++ b/Riot/Modules/MajorUpdate/MajorUpdateManager.swift @@ -31,12 +31,12 @@ final public class MajorUpdateManager: NSObject { var shouldShowMajorUpdate: Bool { guard let lastUsedAppVersion = AppVersion.lastUsed else { - NSLog("[MajorUpdateManager] shouldShowMajorUpdate: Unknown previous version") + MXLog.debug("[MajorUpdateManager] shouldShowMajorUpdate: Unknown previous version") return false } let shouldShowMajorUpdate = (lastUsedAppVersion.compare(Constants.lastMajorAppVersion) == .orderedAscending) - NSLog("[MajorUpdateManager] shouldShowMajorUpdate: \(shouldShowMajorUpdate). AppVersion.lastUsed: \(lastUsedAppVersion). lastMajorAppVersion: \(Constants.lastMajorAppVersion)") + MXLog.debug("[MajorUpdateManager] shouldShowMajorUpdate: \(shouldShowMajorUpdate). AppVersion.lastUsed: \(lastUsedAppVersion). lastMajorAppVersion: \(Constants.lastMajorAppVersion)") return shouldShowMajorUpdate } diff --git a/Riot/Modules/MediaPicker/Library/MediaAlbumContentViewController.m b/Riot/Modules/MediaPicker/Library/MediaAlbumContentViewController.m index 7fcdddd70..598ef399c 100644 --- a/Riot/Modules/MediaPicker/Library/MediaAlbumContentViewController.m +++ b/Riot/Modules/MediaPicker/Library/MediaAlbumContentViewController.m @@ -222,7 +222,7 @@ assets = [PHAsset fetchAssetsInAssetCollection:assetsCollection options:options]; - NSLog(@"[MediaAlbumVC] lists %tu assets", assets.count); + MXLogDebug(@"[MediaAlbumVC] lists %tu assets", assets.count); } else { diff --git a/Riot/Modules/MediaPicker/MediaPickerViewController.m b/Riot/Modules/MediaPicker/MediaPickerViewController.m index f8c382210..6b7725a11 100644 --- a/Riot/Modules/MediaPicker/MediaPickerViewController.m +++ b/Riot/Modules/MediaPicker/MediaPickerViewController.m @@ -291,7 +291,7 @@ } else { - NSLog(@"[MediaPickerVC] Fails to open settings"); + MXLogDebug(@"[MediaPickerVC] Fails to open settings"); } }]; }]]; @@ -372,7 +372,7 @@ PHAssetCollection *assetCollection = smartAlbums[0]; recentCaptures = [PHAsset fetchAssetsInAssetCollection:assetCollection options:options]; - NSLog(@"[MediaPickerVC] lists %tu assets that were recently added to the photo library", recentCaptures.count); + MXLogDebug(@"[MediaPickerVC] lists %tu assets that were recently added to the photo library", recentCaptures.count); } else { @@ -435,7 +435,7 @@ [albums enumerateObjectsUsingBlock:^(PHAssetCollection *collection, NSUInteger idx, BOOL *stop) { PHFetchResult *assets = [PHAsset fetchAssetsInAssetCollection:collection options:options]; - NSLog(@"album title %@, estimatedAssetCount %tu", collection.localizedTitle, assets.count); + MXLogDebug(@"album title %@, estimatedAssetCount %tu", collection.localizedTitle, assets.count); if (assets.count) { @@ -541,7 +541,7 @@ if (imageData) { - NSLog(@"[MediaPickerVC] didSelectAsset: Got image data"); + MXLogDebug(@"[MediaPickerVC] didSelectAsset: Got image data"); CFStringRef uti = (__bridge CFStringRef)dataUTI; NSString *mimeType = (__bridge_transfer NSString *) UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType); @@ -551,7 +551,7 @@ } else { - NSLog(@"[MediaPickerVC] didSelectAsset: Failed to get image data for asset"); + MXLogDebug(@"[MediaPickerVC] didSelectAsset: Failed to get image data for asset"); // Alert user NSError *error = info[@"PHImageErrorKey"]; @@ -570,7 +570,7 @@ } else { - NSLog(@"[MediaPickerVC] didSelectAsset: Failed to get image for asset"); + MXLogDebug(@"[MediaPickerVC] didSelectAsset: Failed to get image for asset"); self->isValidationInProgress = NO; // Alert user @@ -610,7 +610,7 @@ { if ([asset isKindOfClass:[AVURLAsset class]]) { - NSLog(@"[MediaPickerVC] didSelectAsset: Got AVAsset for video"); + MXLogDebug(@"[MediaPickerVC] didSelectAsset: Got AVAsset for video"); AVURLAsset *avURLAsset = (AVURLAsset*)asset; // Validate first the selected video @@ -627,13 +627,13 @@ } else { - NSLog(@"[MediaPickerVC] Selected video asset is not initialized from an URL!"); + MXLogDebug(@"[MediaPickerVC] Selected video asset is not initialized from an URL!"); self->isValidationInProgress = NO; } } else { - NSLog(@"[MediaPickerVC] didSelectAsset: Failed to get image for asset"); + MXLogDebug(@"[MediaPickerVC] didSelectAsset: Failed to get image for asset"); self->isValidationInProgress = NO; // Alert user @@ -650,7 +650,7 @@ } else { - NSLog(@"[MediaPickerVC] didSelectAsset: Unexpected media type"); + MXLogDebug(@"[MediaPickerVC] didSelectAsset: Unexpected media type"); } } diff --git a/Riot/Modules/PublicRoomList/DataSources/PublicRoomsDirectoryDataSource.m b/Riot/Modules/PublicRoomList/DataSources/PublicRoomsDirectoryDataSource.m index 03fb2f94c..e69035aa0 100644 --- a/Riot/Modules/PublicRoomList/DataSources/PublicRoomsDirectoryDataSource.m +++ b/Riot/Modules/PublicRoomList/DataSources/PublicRoomsDirectoryDataSource.m @@ -302,7 +302,7 @@ static NSString *const kNSFWKeyword = @"nsfw"; self->publicRoomsRequest = nil; - NSLog(@"[PublicRoomsDirectoryDataSource] Failed to fecth public rooms."); + MXLogDebug(@"[PublicRoomsDirectoryDataSource] Failed to fecth public rooms."); [self setState:MXKDataSourceStateFailed]; diff --git a/Riot/Modules/Reauthentication/ReauthenticationCoordinator.swift b/Riot/Modules/Reauthentication/ReauthenticationCoordinator.swift index ba805e3de..14c7887c3 100644 --- a/Riot/Modules/Reauthentication/ReauthenticationCoordinator.swift +++ b/Riot/Modules/Reauthentication/ReauthenticationCoordinator.swift @@ -80,7 +80,7 @@ final class ReauthenticationCoordinator: ReauthenticationCoordinatorType { switch authenticatedEnpointStatus { case .authenticationNotNeeded: - NSLog("[ReauthenticationCoordinator] No need to login again") + MXLog.debug("[ReauthenticationCoordinator] No need to login again") self.delegate?.reauthenticationCoordinatorDidComplete(self, withAuthenticationParameters: nil) case .authenticationNeeded(let authenticationSession): self.start(with: authenticationSession) diff --git a/Riot/Modules/Room/CellData/RoomBubbleCellData.m b/Riot/Modules/Room/CellData/RoomBubbleCellData.m index 28987ffba..423b84426 100644 --- a/Riot/Modules/Room/CellData/RoomBubbleCellData.m +++ b/Riot/Modules/Room/CellData/RoomBubbleCellData.m @@ -190,7 +190,7 @@ static NSAttributedString *timestampVerticalWhitespace = nil; // which takes place on the main thread. if ([NSThread currentThread] != [NSThread mainThread]) { - NSLog(@"[RoomBubbleCellData] prepareBubbleComponentsPosition called on wrong thread"); + MXLogDebug(@"[RoomBubbleCellData] prepareBubbleComponentsPosition called on wrong thread"); dispatch_sync(dispatch_get_main_queue(), ^{ [self refreshBubbleComponentsPosition]; }); @@ -217,7 +217,7 @@ static NSAttributedString *timestampVerticalWhitespace = nil; // is requested during the rendering step which takes place on the main thread. if ([NSThread currentThread] != [NSThread mainThread]) { - NSLog(@"[RoomBubbleCellData] attributedTextMessage called on wrong thread"); + MXLogDebug(@"[RoomBubbleCellData] attributedTextMessage called on wrong thread"); dispatch_sync(dispatch_get_main_queue(), ^{ self.attributedTextMessage = [self refreshAttributedTextMessage]; }); @@ -544,7 +544,7 @@ static NSAttributedString *timestampVerticalWhitespace = nil; // which takes place on the main thread. if ([NSThread currentThread] != [NSThread mainThread]) { - NSLog(@"[RoomBubbleCellData] prepareBubbleComponentsPosition called on wrong thread"); + MXLogDebug(@"[RoomBubbleCellData] prepareBubbleComponentsPosition called on wrong thread"); dispatch_sync(dispatch_get_main_queue(), ^{ updateAdditionalHeight(); }); diff --git a/Riot/Modules/Room/DataSources/RoomDataSource.m b/Riot/Modules/Room/DataSources/RoomDataSource.m index 0a639ebc2..831f96634 100644 --- a/Riot/Modules/Room/DataSources/RoomDataSource.m +++ b/Riot/Modules/Room/DataSources/RoomDataSource.m @@ -111,13 +111,13 @@ const CGFloat kTypingCellHeight = 24; if (![self.mxSession.store hasLoadedAllRoomMembersForRoom:self.roomId]) { [self.room members:^(MXRoomMembers *roomMembers) { - NSLog(@"[MXKRoomDataSource] finalizeRoomDataSource: All room members have been retrieved"); + MXLogDebug(@"[MXKRoomDataSource] finalizeRoomDataSource: All room members have been retrieved"); // Refresh the full table [self.delegate dataSource:self didCellChange:nil]; } failure:^(NSError *error) { - NSLog(@"[MXKRoomDataSource] finalizeRoomDataSource: Cannot retrieve all room members"); + MXLogDebug(@"[MXKRoomDataSource] finalizeRoomDataSource: Cannot retrieve all room members"); }]; } @@ -830,7 +830,7 @@ const CGFloat kTypingCellHeight = 24; } failure:^(NSError * _Nonnull error) { - NSLog(@"[RoomDataSource] updateKeyVerificationIfNeededForRoomBubbleCellData; keyVerificationFromKeyVerificationEvent fails with error: %@", error); + MXLogDebug(@"[RoomDataSource] updateKeyVerificationIfNeededForRoomBubbleCellData; keyVerificationFromKeyVerificationEvent fails with error: %@", error); bubbleCellData.isKeyVerificationOperationPending = NO; }]; diff --git a/Riot/Modules/Room/EditHistory/EditHistoryCoordinatorBridgePresenter.swift b/Riot/Modules/Room/EditHistory/EditHistoryCoordinatorBridgePresenter.swift index d6a4bb7ad..1e0dab2f8 100644 --- a/Riot/Modules/Room/EditHistory/EditHistoryCoordinatorBridgePresenter.swift +++ b/Riot/Modules/Room/EditHistory/EditHistoryCoordinatorBridgePresenter.swift @@ -91,7 +91,7 @@ final class EditHistoryCoordinatorBridgePresenter: NSObject { func createEventFormatter(session: MXSession) -> EventFormatter? { guard let formatter = EventFormatter(matrixSession: session) else { - print("[EditHistoryCoordinatorBridgePresenter] createEventFormatter: Cannot build formatter") + MXLog.debug("[EditHistoryCoordinatorBridgePresenter] createEventFormatter: Cannot build formatter") return nil } diff --git a/Riot/Modules/Room/EditHistory/EditHistoryViewModel.swift b/Riot/Modules/Room/EditHistory/EditHistoryViewModel.swift index 1a1b0aede..2f9b4f0d0 100644 --- a/Riot/Modules/Room/EditHistory/EditHistoryViewModel.swift +++ b/Riot/Modules/Room/EditHistory/EditHistoryViewModel.swift @@ -94,12 +94,12 @@ final class EditHistoryViewModel: EditHistoryViewModelType { private func loadMoreHistory() { guard self.canLoadMoreHistory() else { - print("[EditHistoryViewModel] loadMoreHistory: pending loading or all data loaded") + MXLog.debug("[EditHistoryViewModel] loadMoreHistory: pending loading or all data loaded") return } guard self.operation == nil else { - print("[EditHistoryViewModel] loadMoreHistory: operation already pending") + MXLog.debug("[EditHistoryViewModel] loadMoreHistory: operation already pending") return } @@ -212,7 +212,7 @@ final class EditHistoryViewModel: EditHistoryViewModelType { private func process(editEvent: MXEvent) -> EditHistoryMessage? { // Create a temporary MXEvent that represents this edition guard let editedEvent = self.event.editedEvent(fromReplacementEvent: editEvent) else { - print("[EditHistoryViewModel] processEditEvent: Cannot build edited event: \(editEvent.eventId ?? "")") + MXLog.debug("[EditHistoryViewModel] processEditEvent: Cannot build edited event: \(editEvent.eventId ?? "")") return nil } @@ -223,7 +223,7 @@ final class EditHistoryViewModel: EditHistoryViewModelType { let formatterError = UnsafeMutablePointer.allocate(capacity: 1) guard let message = self.formatter.attributedString(from: event, with: nil, error: formatterError) else { - print("[EditHistoryViewModel] processEditEvent: cannot format(error: \(formatterError)) event: \(event.eventId ?? "")") + MXLog.debug("[EditHistoryViewModel] processEditEvent: cannot format(error: \(formatterError)) event: \(event.eventId ?? "")") return nil } diff --git a/Riot/Modules/Room/EmojiPicker/Data/EmojiMart/EmojiJSONStore.swift b/Riot/Modules/Room/EmojiPicker/Data/EmojiMart/EmojiJSONStore.swift index 73913dcbf..c875b449e 100644 --- a/Riot/Modules/Room/EmojiPicker/Data/EmojiMart/EmojiJSONStore.swift +++ b/Riot/Modules/Room/EmojiPicker/Data/EmojiMart/EmojiJSONStore.swift @@ -53,7 +53,7 @@ extension EmojiMartStore: Decodable { do { emojiItem = try emojisContainer.decode(EmojiItem.self, forKey: emojiKey) } catch { - print("[EmojiJSONStore] init(from decoder: Decoder) failed to parse emojiItem \(emojiKey) with error: \(error)") + MXLog.debug("[EmojiJSONStore] init(from decoder: Decoder) failed to parse emojiItem \(emojiKey) with error: \(error)") emojiItem = nil } diff --git a/Riot/Modules/Room/EmojiPicker/Data/EmojiMart/EmojiMartStore.swift b/Riot/Modules/Room/EmojiPicker/Data/EmojiMart/EmojiMartStore.swift index a83e3373d..83e6ce8ce 100644 --- a/Riot/Modules/Room/EmojiPicker/Data/EmojiMart/EmojiMartStore.swift +++ b/Riot/Modules/Room/EmojiPicker/Data/EmojiMart/EmojiMartStore.swift @@ -53,7 +53,7 @@ extension EmojiMartStore: Decodable { do { emojiItem = try emojisContainer.decode(EmojiItem.self, forKey: emojiKey) } catch { - print("[EmojiJSONStore] init(from decoder: Decoder) failed to parse emojiItem \(emojiKey) with error: \(error)") + MXLog.debug("[EmojiJSONStore] init(from decoder: Decoder) failed to parse emojiItem \(emojiKey) with error: \(error)") emojiItem = nil } diff --git a/Riot/Modules/Room/Members/Detail/RoomMemberDetailsViewController.m b/Riot/Modules/Room/Members/Detail/RoomMemberDetailsViewController.m index 82a621795..ed313cffb 100644 --- a/Riot/Modules/Room/Members/Detail/RoomMemberDetailsViewController.m +++ b/Riot/Modules/Room/Members/Detail/RoomMemberDetailsViewController.m @@ -1156,7 +1156,7 @@ __strong __typeof(weakSelf)self = weakSelf; [self stopActivityIndicator]; - NSLog(@"[RoomMemberDetailVC] Ban user (%@) failed", self.mxRoomMember.userId); + MXLogDebug(@"[RoomMemberDetailVC] Ban user (%@) failed", self.mxRoomMember.userId); //Alert user [[AppDelegate theDelegate] showErrorAsAlert:error]; @@ -1220,7 +1220,7 @@ __strong __typeof(weakSelf)self = weakSelf; [self stopActivityIndicator]; - NSLog(@"[RoomMemberDetailVC] Removing user (%@) failed", self.mxRoomMember.userId); + MXLogDebug(@"[RoomMemberDetailVC] Removing user (%@) failed", self.mxRoomMember.userId); //Alert user [[AppDelegate theDelegate] showErrorAsAlert:error]; diff --git a/Riot/Modules/Room/Members/RoomParticipantsViewController.m b/Riot/Modules/Room/Members/RoomParticipantsViewController.m index 1f9e4bc40..ec814191d 100644 --- a/Riot/Modules/Room/Members/RoomParticipantsViewController.m +++ b/Riot/Modules/Room/Members/RoomParticipantsViewController.m @@ -1315,7 +1315,7 @@ MXStrongifyAndReturnIfNil(self); [self removePendingActionMask]; - NSLog(@"[RoomParticipantsVC] Leave room %@ failed", self.mxRoom.roomId); + MXLogDebug(@"[RoomParticipantsVC] Leave room %@ failed", self.mxRoom.roomId); // Alert user [[AppDelegate theDelegate] showErrorAsAlert:error]; @@ -1407,7 +1407,7 @@ MXStrongifyAndReturnIfNil(self); [self removePendingActionMask]; - NSLog(@"[RoomParticipantsVC] Kick %@ failed", memberUserId); + MXLogDebug(@"[RoomParticipantsVC] Kick %@ failed", memberUserId); // Alert user [[AppDelegate theDelegate] showErrorAsAlert:error]; @@ -1455,7 +1455,7 @@ MXStrongifyAndReturnIfNil(self); [self removePendingActionMask]; - NSLog(@"[RoomParticipantsVC] Revoke 3pid invite failed"); + MXLogDebug(@"[RoomParticipantsVC] Revoke 3pid invite failed"); // Alert user [[AppDelegate theDelegate] showErrorAsAlert:error]; @@ -1537,7 +1537,7 @@ __strong __typeof(weakSelf)self = weakSelf; [self removePendingActionMask]; - NSLog(@"[RoomParticipantsVC] Invite %@ failed", participantId); + MXLogDebug(@"[RoomParticipantsVC] Invite %@ failed", participantId); // Alert user [[AppDelegate theDelegate] showErrorAsAlert:error]; }]; @@ -1574,7 +1574,7 @@ __strong __typeof(weakSelf)self = weakSelf; [self removePendingActionMask]; - NSLog(@"[RoomParticipantsVC] Invite be email %@ failed", participantId); + MXLogDebug(@"[RoomParticipantsVC] Invite be email %@ failed", participantId); // Alert user if ([error.domain isEqualToString:kMXRestClientErrorDomain] @@ -1605,7 +1605,7 @@ __strong __typeof(weakSelf)self = weakSelf; [self removePendingActionMask]; - NSLog(@"[RoomParticipantsVC] Invite %@ failed", participantId); + MXLogDebug(@"[RoomParticipantsVC] Invite %@ failed", participantId); // Alert user [[AppDelegate theDelegate] showErrorAsAlert:error]; }]; diff --git a/Riot/Modules/Room/ReactionHistory/ReactionHistoryViewModel.swift b/Riot/Modules/Room/ReactionHistory/ReactionHistoryViewModel.swift index 12fa4e4aa..b98ec19c5 100644 --- a/Riot/Modules/Room/ReactionHistory/ReactionHistoryViewModel.swift +++ b/Riot/Modules/Room/ReactionHistory/ReactionHistoryViewModel.swift @@ -97,12 +97,12 @@ final class ReactionHistoryViewModel: ReactionHistoryViewModelType { private func loadMoreHistory() { guard self.canLoadMoreHistory() else { - print("[ReactionHistoryViewModel] loadMoreHistory: pending loading or all data loaded") + MXLog.debug("[ReactionHistoryViewModel] loadMoreHistory: pending loading or all data loaded") return } guard self.operation == nil else { - print("[ReactionHistoryViewModel] loadMoreHistory: operation already pending") + MXLog.debug("[ReactionHistoryViewModel] loadMoreHistory: operation already pending") return } diff --git a/Riot/Modules/Room/RoomViewController.m b/Riot/Modules/Room/RoomViewController.m index d1f6babe1..fb4b7db8f 100644 --- a/Riot/Modules/Room/RoomViewController.m +++ b/Riot/Modules/Room/RoomViewController.m @@ -1180,7 +1180,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; } failure:^(NSError *error) { - NSLog(@"[RoomVC] Join roomAlias (%@) failed", roomAlias); + MXLogDebug(@"[RoomVC] Join roomAlias (%@) failed", roomAlias); //Alert user [[AppDelegate theDelegate] showErrorAsAlert:error]; @@ -1243,14 +1243,14 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; { [self.roomDataSource sendReplyToEventWithId:customizedRoomDataSource.selectedEventId withTextMessage:msgTxt success:nil failure:^(NSError *error) { // Just log the error. The message will be displayed in red in the room history - NSLog(@"[MXKRoomViewController] sendTextMessage failed."); + MXLogDebug(@"[MXKRoomViewController] sendTextMessage failed."); }]; } else if (self.inputToolBarSendMode == RoomInputToolbarViewSendModeEdit && customizedRoomDataSource.selectedEventId) { [self.roomDataSource replaceTextMessageForEventWithId:customizedRoomDataSource.selectedEventId withTextMessage:msgTxt success:nil failure:^(NSError *error) { // Just log the error. The message will be displayed in red - NSLog(@"[MXKRoomViewController] sendTextMessage failed."); + MXLogDebug(@"[MXKRoomViewController] sendTextMessage failed."); }]; } else @@ -1259,7 +1259,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; [self.roomDataSource sendTextMessage:msgTxt success:nil failure:^(NSError *error) { // Just log the error. The message will be displayed in red in the room history - NSLog(@"[MXKRoomViewController] sendTextMessage failed."); + MXLogDebug(@"[MXKRoomViewController] sendTextMessage failed."); }]; } @@ -1344,7 +1344,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; if (previewHeader) { // Here [destroy] is called before [viewWillDisappear:] - NSLog(@"[RoomVC] destroyed whereas it is still visible"); + MXLogDebug(@"[RoomVC] destroyed whereas it is still visible"); [previewHeader removeFromSuperview]; previewHeader = nil; @@ -1922,7 +1922,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; [self.navigationController pushViewController:stickerPickerVC animated:YES]; } failure:^(NSError * _Nonnull error) { - NSLog(@"[RoomVC] Cannot display widget %@", widget); + MXLogDebug(@"[RoomVC] Cannot display widget %@", widget); [[AppDelegate theDelegate] showErrorAsAlert:error]; }]; } @@ -2037,7 +2037,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; // or if the view controller is not embedded inside a split view controller yet. if (isVisible && (isSizeTransitionInProgress == YES || !self.splitViewController)) { - NSLog(@"[RoomVC] Show preview header ignored"); + MXLogDebug(@"[RoomVC] Show preview header ignored"); return; } @@ -2619,7 +2619,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; } else { - NSLog(@"[RoomViewController] didRecognizeAction:inCell:userInfo tap on attachment with event state MXEventSentStateFailed. Selected event is nil for event id %@", eventId); + MXLogDebug(@"[RoomViewController] didRecognizeAction:inCell:userInfo tap on attachment with event state MXEventSentStateFailed. Selected event is nil for event id %@", eventId); } } else if (((MXKRoomBubbleTableViewCell*)cell).bubbleData.attachment.type == MXKAttachmentTypeSticker) @@ -2738,7 +2738,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; } else { - NSLog(@"[RoomVC] didRecognizeAction:inCell:userInfo Warning: The application does not have the permission to join/answer the group call"); + MXLogDebug(@"[RoomVC] didRecognizeAction:inCell:userInfo Warning: The application does not have the permission to join/answer the group call"); } }]; @@ -3132,7 +3132,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; __strong __typeof(weakSelf)self = weakSelf; [self stopActivityIndicator]; - NSLog(@"[RoomVC] Redact event (%@) failed", selectedEvent.eventId); + MXLogDebug(@"[RoomVC] Redact event (%@) failed", selectedEvent.eventId); //Alert user [[AppDelegate theDelegate] showErrorAsAlert:error]; @@ -3163,7 +3163,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; } else { - NSLog(@"[RoomViewController] Contextual menu permalink action failed. Permalink is nil room id/event id: %@/%@", selectedEvent.roomId, selectedEvent.eventId); + MXLogDebug(@"[RoomViewController] Contextual menu permalink action failed. Permalink is nil room id/event id: %@/%@", selectedEvent.roomId, selectedEvent.eventId); } } @@ -3283,7 +3283,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; __strong __typeof(weakSelf)self = weakSelf; [self stopActivityIndicator]; - NSLog(@"[RoomVC] Ignore user (%@) failed", selectedEvent.sender); + MXLogDebug(@"[RoomVC] Ignore user (%@) failed", selectedEvent.sender); //Alert user [[AppDelegate theDelegate] showErrorAsAlert:error]; @@ -3309,7 +3309,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; __strong __typeof(weakSelf)self = weakSelf; [self stopActivityIndicator]; - NSLog(@"[RoomVC] Report event (%@) failed", selectedEvent.eventId); + MXLogDebug(@"[RoomVC] Report event (%@) failed", selectedEvent.eventId); //Alert user [[AppDelegate theDelegate] showErrorAsAlert:error]; @@ -3744,7 +3744,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; } else { - NSLog(@"RoomViewController: Warning: The application does not have the permission to place the call"); + MXLogDebug(@"RoomViewController: Warning: The application does not have the permission to place the call"); } } }]; @@ -4260,7 +4260,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; } failure:^(NSError *error) { [self stopActivityIndicator]; - NSLog(@"[RoomVC] Failed to reject an invited room (%@) failed", self.roomDataSource.room.roomId); + MXLogDebug(@"[RoomVC] Failed to reject an invited room (%@) failed", self.roomDataSource.room.roomId); }]; } @@ -4542,7 +4542,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; [[UIApplication sharedApplication] vc_open:adminContactURL completionHandler:^(BOOL success) { if (!success) { - NSLog(@"[RoomVC] refreshActivitiesViewDisplay: adminContact(%@) cannot be opened", adminContactURL); + MXLogDebug(@"[RoomVC] refreshActivitiesViewDisplay: adminContact(%@) cannot be opened", adminContactURL); } }]; }]; @@ -4570,7 +4570,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; else { // Else auto join it via the server that sent the event - NSLog(@"[RoomVC] Auto join an upgraded room: %@ -> %@. Sender: %@", self->customizedRoomDataSource.roomState.roomId, + MXLogDebug(@"[RoomVC] Auto join an upgraded room: %@ -> %@. Sender: %@", self->customizedRoomDataSource.roomState.roomId, replacementRoomId, stoneTombEvent.sender); NSString *viaSenderServer = [MXTools serverNameInMatrixIdentifier:stoneTombEvent.sender]; @@ -4586,7 +4586,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; } failure:^(NSError *error) { [self stopActivityIndicator]; - NSLog(@"[RoomVC] Failed to join an upgraded room. Error: %@", + MXLogDebug(@"[RoomVC] Failed to join an upgraded room. Error: %@", error); [[AppDelegate theDelegate] showErrorAsAlert:error]; }]; @@ -4624,7 +4624,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; [[UIApplication sharedApplication] vc_open:adminContactURL completionHandler:^(BOOL success) { if (!success) { - NSLog(@"[RoomVC] refreshActivitiesViewDisplay: adminContact(%@) cannot be opened", adminContactURL); + MXLogDebug(@"[RoomVC] refreshActivitiesViewDisplay: adminContact(%@) cannot be opened", adminContactURL); } }]; }]; @@ -4922,7 +4922,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; if ([customizedRoomDataSource.selectedEventId isEqualToString:previousId]) { - NSLog(@"[RoomVC] eventDidChangeIdentifier: Update selectedEventId"); + MXLogDebug(@"[RoomVC] eventDidChangeIdentifier: Update selectedEventId"); customizedRoomDataSource.selectedEventId = event.eventId; } } @@ -5275,7 +5275,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; } failure:^(NSError *error) { - NSLog(@"[RoomVC] Invite %@ failed", participantId); + MXLogDebug(@"[RoomVC] Invite %@ failed", participantId); // Alert user [[AppDelegate theDelegate] showErrorAsAlert:error]; @@ -5306,7 +5306,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; } failure:^(NSError *error) { - NSLog(@"[RoomVC] Invite be email %@ failed", participantId); + MXLogDebug(@"[RoomVC] Invite be email %@ failed", participantId); // Alert user if ([error.domain isEqualToString:kMXRestClientErrorDomain] && error.code == MXRestClientErrorMissingIdentityServer) @@ -5329,7 +5329,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; } failure:^(NSError *error) { - NSLog(@"[RoomVC] Invite %@ failed", participantId); + MXLogDebug(@"[RoomVC] Invite %@ failed", participantId); // Alert user [[AppDelegate theDelegate] showErrorAsAlert:error]; @@ -5404,7 +5404,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; - (void)presentReviewUnverifiedSessionsAlert { - NSLog(@"[MasterTabBarController] presentReviewUnverifiedSessionsAlertWithSession"); + MXLogDebug(@"[MasterTabBarController] presentReviewUnverifiedSessionsAlertWithSession"); [currentAlert dismissViewControllerAnimated:NO completion:nil]; @@ -5774,7 +5774,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; } else { - NSLog(@"[RoomViewController] Contextual menu copy failed. Text is nil for room id/event id: %@/%@", selectedComponent.event.roomId, selectedComponent.event.eventId); + MXLogDebug(@"[RoomViewController] Contextual menu copy failed. Text is nil for room id/event id: %@/%@", selectedComponent.event.roomId, selectedComponent.event.eventId); } [self hideContextualMenuAnimated:YES]; @@ -5952,26 +5952,26 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; [self.roomDataSource sendImage:imageData mimeType:mimeType success:nil failure:^(NSError *error) { // Nothing to do. The image is marked as unsent in the room history by the datasource - NSLog(@"[MXKRoomViewController] sendImage failed."); + MXLogDebug(@"[MXKRoomViewController] sendImage failed."); }]; } else if (fileUTI.isVideo) { [(RoomDataSource*)self.roomDataSource sendVideo:url success:nil failure:^(NSError *error) { // Nothing to do. The video is marked as unsent in the room history by the datasource - NSLog(@"[MXKRoomViewController] sendVideo failed."); + MXLogDebug(@"[MXKRoomViewController] sendVideo failed."); }]; } else if (fileUTI.isFile) { [self.roomDataSource sendFile:url mimeType:mimeType success:nil failure:^(NSError *error) { // Nothing to do. The file is marked as unsent in the room history by the datasource - NSLog(@"[MXKRoomViewController] sendFile failed."); + MXLogDebug(@"[MXKRoomViewController] sendFile failed."); }]; } else { - NSLog(@"[MXKRoomViewController] File upload using MIME type %@ is not supported.", mimeType); + MXLogDebug(@"[MXKRoomViewController] File upload using MIME type %@ is not supported.", mimeType); [[AppDelegate theDelegate] showAlertWithTitle:NSLocalizedStringFromTable(@"file_upload_error_title", @"Vector", nil) message:NSLocalizedStringFromTable(@"file_upload_error_unsupported_file_type_message", @"Vector", nil)]; diff --git a/Riot/Modules/Room/Settings/RoomSettingsViewController.m b/Riot/Modules/Room/Settings/RoomSettingsViewController.m index e3ab9deb7..634468fe8 100644 --- a/Riot/Modules/Room/Settings/RoomSettingsViewController.m +++ b/Riot/Modules/Room/Settings/RoomSettingsViewController.m @@ -905,7 +905,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } else { - NSLog(@"[RoomSettingsViewController] Copy room id failed. Room id is nil"); + MXLogDebug(@"[RoomSettingsViewController] Copy room id failed. Room id is nil"); } } @@ -1013,7 +1013,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } else { - NSLog(@"[RoomSettingsViewController] Copy room address failed. Room address is nil"); + MXLogDebug(@"[RoomSettingsViewController] Copy room address failed. Room address is nil"); } } @@ -1038,7 +1038,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } else { - NSLog(@"[RoomSettingsViewController] Copy room URL failed. Room URL is nil"); + MXLogDebug(@"[RoomSettingsViewController] Copy room URL failed. Room URL is nil"); } } @@ -1120,7 +1120,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } failure:^(NSError *error) { - NSLog(@"[RoomSettingsViewController] request to get directory visibility failed"); + MXLogDebug(@"[RoomSettingsViewController] request to get directory visibility failed"); if (weakSelf) { @@ -1464,7 +1464,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } failure:^(NSError *error) { - NSLog(@"[RoomSettingsViewController] Image upload failed"); + MXLogDebug(@"[RoomSettingsViewController] Image upload failed"); if (weakSelf) { @@ -1505,7 +1505,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } failure:^(NSError *error) { - NSLog(@"[RoomSettingsViewController] Failed to update the room avatar"); + MXLogDebug(@"[RoomSettingsViewController] Failed to update the room avatar"); if (weakSelf) { @@ -1547,7 +1547,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } failure:^(NSError *error) { - NSLog(@"[RoomSettingsViewController] Rename room failed"); + MXLogDebug(@"[RoomSettingsViewController] Rename room failed"); if (weakSelf) { @@ -1589,7 +1589,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } failure:^(NSError *error) { - NSLog(@"[RoomSettingsViewController] Rename topic failed"); + MXLogDebug(@"[RoomSettingsViewController] Rename topic failed"); if (weakSelf) { @@ -1631,7 +1631,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } failure:^(NSError *error) { - NSLog(@"[RoomSettingsViewController] Update guest access failed"); + MXLogDebug(@"[RoomSettingsViewController] Update guest access failed"); if (weakSelf) { @@ -1673,7 +1673,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } failure:^(NSError *error) { - NSLog(@"[RoomSettingsViewController] Update join rule failed"); + MXLogDebug(@"[RoomSettingsViewController] Update join rule failed"); if (weakSelf) { @@ -1715,7 +1715,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } failure:^(NSError *error) { - NSLog(@"[RoomSettingsViewController] Update history visibility failed"); + MXLogDebug(@"[RoomSettingsViewController] Update history visibility failed"); if (weakSelf) { @@ -1769,7 +1769,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } failure:^(NSError *error) { - NSLog(@"[RoomSettingsViewController] Add room aliases failed"); + MXLogDebug(@"[RoomSettingsViewController] Add room aliases failed"); if (weakSelf) { @@ -1822,7 +1822,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } failure:^(NSError *error) { - NSLog(@"[RoomSettingsViewController] Remove room aliases failed"); + MXLogDebug(@"[RoomSettingsViewController] Remove room aliases failed"); if (weakSelf) { @@ -1863,7 +1863,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } failure:^(NSError *error) { - NSLog(@"[RoomSettingsViewController] Update canonical alias failed"); + MXLogDebug(@"[RoomSettingsViewController] Update canonical alias failed"); if (weakSelf) { @@ -1909,7 +1909,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } failure:^(NSError *error) { - NSLog(@"[RoomSettingsViewController] Update room communities failed"); + MXLogDebug(@"[RoomSettingsViewController] Update room communities failed"); if (weakSelf) { @@ -2007,7 +2007,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } failure:^(NSError *error) { - NSLog(@"[RoomSettingsViewController] Altering DMness failed"); + MXLogDebug(@"[RoomSettingsViewController] Altering DMness failed"); if (weakSelf) { @@ -2047,7 +2047,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } failure:^(NSError *error) { - NSLog(@"[RoomSettingsViewController] Update room directory visibility failed"); + MXLogDebug(@"[RoomSettingsViewController] Update room directory visibility failed"); if (weakSelf) { @@ -2089,7 +2089,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } failure:^(NSError *error) { - NSLog(@"[RoomSettingsViewController] Enabling encrytion failed. Error: %@", error); + MXLogDebug(@"[RoomSettingsViewController] Enabling encrytion failed. Error: %@", error); if (weakSelf) { @@ -2912,7 +2912,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti // Sanity check if (!cell) { - NSLog(@"[RoomSettingsViewController] cellForRowAtIndexPath: invalid indexPath"); + MXLogDebug(@"[RoomSettingsViewController] cellForRowAtIndexPath: invalid indexPath"); cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil]; } @@ -3497,7 +3497,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti [self stopActivityIndicator]; - NSLog(@"[RoomSettingsViewController] Leave room failed"); + MXLogDebug(@"[RoomSettingsViewController] Leave room failed"); // Alert user [[AppDelegate theDelegate] showErrorAsAlert:error]; diff --git a/Riot/Modules/Room/Views/BubbleCells/Call/Group/RoomGroupCallStatusBubbleCell.swift b/Riot/Modules/Room/Views/BubbleCells/Call/Group/RoomGroupCallStatusBubbleCell.swift index 15d7a9cd6..62cebfd70 100644 --- a/Riot/Modules/Room/Views/BubbleCells/Call/Group/RoomGroupCallStatusBubbleCell.swift +++ b/Riot/Modules/Room/Views/BubbleCells/Call/Group/RoomGroupCallStatusBubbleCell.swift @@ -201,7 +201,7 @@ class RoomGroupCallStatusBubbleCell: RoomBaseCallBubbleCell { let events = bubbleCellData.allLinkedEvents() - NSLog("[RoomGroupCallStatusBubbleCell] render: \(events.count) events: \(events)") + MXLog.debug("[RoomGroupCallStatusBubbleCell] render: \(events.count) events: \(events)") guard let widgetEvent = events .first(where: { diff --git a/Riot/Modules/Room/Views/BubbleCells/KeyVerification/KeyVerificationConclusionBubbleCell.swift b/Riot/Modules/Room/Views/BubbleCells/KeyVerification/KeyVerificationConclusionBubbleCell.swift index 70353531f..17fada772 100644 --- a/Riot/Modules/Room/Views/BubbleCells/KeyVerification/KeyVerificationConclusionBubbleCell.swift +++ b/Riot/Modules/Room/Views/BubbleCells/KeyVerification/KeyVerificationConclusionBubbleCell.swift @@ -49,7 +49,7 @@ class KeyVerificationConclusionBubbleCell: KeyVerificationBaseBubbleCell { guard let keyVerificationCellInnerContentView = self.keyVerificationCellInnerContentView, let bubbleData = self.bubbleData as? RoomBubbleCellData, let viewData = self.viewData(from: bubbleData) else { - NSLog("[KeyVerificationConclusionBubbleCell] Fail to render \(String(describing: cellData))") + MXLog.debug("[KeyVerificationConclusionBubbleCell] Fail to render \(String(describing: cellData))") return } diff --git a/Riot/Modules/Room/Views/BubbleCells/KeyVerification/KeyVerificationIncomingRequestApprovalBubbleCell.swift b/Riot/Modules/Room/Views/BubbleCells/KeyVerification/KeyVerificationIncomingRequestApprovalBubbleCell.swift index 3093b5206..f1a5fbac4 100644 --- a/Riot/Modules/Room/Views/BubbleCells/KeyVerification/KeyVerificationIncomingRequestApprovalBubbleCell.swift +++ b/Riot/Modules/Room/Views/BubbleCells/KeyVerification/KeyVerificationIncomingRequestApprovalBubbleCell.swift @@ -61,7 +61,7 @@ class KeyVerificationIncomingRequestApprovalBubbleCell: KeyVerificationBaseBubbl guard let keyVerificationCellInnerContentView = self.keyVerificationCellInnerContentView, let bubbleData = self.bubbleData, let viewData = self.viewData(from: bubbleData) else { - NSLog("[KeyVerificationIncomingRequestApprovalBubbleCell] Fail to render \(String(describing: cellData))") + MXLog.debug("[KeyVerificationIncomingRequestApprovalBubbleCell] Fail to render \(String(describing: cellData))") return } diff --git a/Riot/Modules/Room/Views/BubbleCells/KeyVerification/KeyVerificationRequestStatusBubbleCell.swift b/Riot/Modules/Room/Views/BubbleCells/KeyVerification/KeyVerificationRequestStatusBubbleCell.swift index b5af25a5a..6221bb0e9 100644 --- a/Riot/Modules/Room/Views/BubbleCells/KeyVerification/KeyVerificationRequestStatusBubbleCell.swift +++ b/Riot/Modules/Room/Views/BubbleCells/KeyVerification/KeyVerificationRequestStatusBubbleCell.swift @@ -52,10 +52,10 @@ class KeyVerificationRequestStatusBubbleCell: KeyVerificationBaseBubbleCell { super.render(cellData) guard let keyVerificationCellInnerContentView = self.keyVerificationCellInnerContentView, - let roomBubbleCellData = self.bubbleData as? RoomBubbleCellData, - let viewData = self.viewData(from: roomBubbleCellData) else { - NSLog("[KeyVerificationRequestStatusBubbleCell] Fail to render \(String(describing: cellData))") - return + let roomBubbleCellData = self.bubbleData as? RoomBubbleCellData, + let viewData = self.viewData(from: roomBubbleCellData) else { + MXLog.debug("[KeyVerificationRequestStatusBubbleCell] Fail to render \(String(describing: cellData))") + return } keyVerificationCellInnerContentView.title = viewData.title diff --git a/Riot/Modules/Room/Views/BubbleCells/RoomCreationIntro/RoomCreationIntroCell.swift b/Riot/Modules/Room/Views/BubbleCells/RoomCreationIntro/RoomCreationIntroCell.swift index a4d75b31a..d0204a410 100644 --- a/Riot/Modules/Room/Views/BubbleCells/RoomCreationIntro/RoomCreationIntroCell.swift +++ b/Riot/Modules/Room/Views/BubbleCells/RoomCreationIntro/RoomCreationIntroCell.swift @@ -93,14 +93,14 @@ class RoomCreationIntroCell: MXKRoomBubbleTableViewCell { super.render(cellData) guard let bubbleCellContentView = self.bubbleCellContentView else { - NSLog("[RoomCreationIntroCell] Fail to load content view") + MXLog.debug("[RoomCreationIntroCell] Fail to load content view") return } guard let bubbleData = self.bubbleData, - let viewData = self.viewData(from: bubbleData) else { - NSLog("[RoomCreationIntroCell] Fail to render \(String(describing: cellData))") - return + let viewData = self.viewData(from: bubbleData) else { + MXLog.debug("[RoomCreationIntroCell] Fail to render \(String(describing: cellData))") + return } bubbleCellContentView.fill(with: viewData) diff --git a/Riot/Modules/Room/Views/Title/Expanded/ExpandedRoomTitleView.m b/Riot/Modules/Room/Views/Title/Expanded/ExpandedRoomTitleView.m index e71dc688a..20fa6fab5 100644 --- a/Riot/Modules/Room/Views/Title/Expanded/ExpandedRoomTitleView.m +++ b/Riot/Modules/Room/Views/Title/Expanded/ExpandedRoomTitleView.m @@ -101,7 +101,7 @@ } lazyLoadedMembers:^(MXRoomMembers *lazyLoadedMembers) { onRoomMembers(lazyLoadedMembers, NO); } failure:^(NSError *error) { - NSLog(@"[ExpandedRoomTitleView] refreshDisplay: Cannot get all room members"); + MXLogDebug(@"[ExpandedRoomTitleView] refreshDisplay: Cannot get all room members"); }]; } else diff --git a/Riot/Modules/Room/Views/Title/Preview/PreviewRoomTitleView.m b/Riot/Modules/Room/Views/Title/Preview/PreviewRoomTitleView.m index 52327d07d..9ad2037e1 100644 --- a/Riot/Modules/Room/Views/Title/Preview/PreviewRoomTitleView.m +++ b/Riot/Modules/Room/Views/Title/Preview/PreviewRoomTitleView.m @@ -226,7 +226,7 @@ }lazyLoadedMembers:^(MXRoomMembers *lazyLoadedMembers) { onRoomMembers(lazyLoadedMembers, NO); } failure:^(NSError *error) { - NSLog(@"[PreviewRoomTitleView] refreshDisplay: Cannot get all room members"); + MXLogDebug(@"[PreviewRoomTitleView] refreshDisplay: Cannot get all room members"); }]; } else diff --git a/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewController.swift b/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewController.swift index b8a328289..306c3bcb8 100644 --- a/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewController.swift +++ b/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewController.swift @@ -229,7 +229,7 @@ final class SecretsRecoveryWithKeyViewController: UIViewController { do { documentContent = try String(contentsOf: documentURL) } catch { - print("[SecretsRecoveryWithKeyViewController] Error: \(error)") + MXLog.debug("[SecretsRecoveryWithKeyViewController] Error: \(error)") documentContent = nil } diff --git a/Riot/Modules/Secrets/Recover/SecretsRecoveryCoordinatorBridgePresenter.swift b/Riot/Modules/Secrets/Recover/SecretsRecoveryCoordinatorBridgePresenter.swift index 0ddff770c..9ec041e61 100644 --- a/Riot/Modules/Secrets/Recover/SecretsRecoveryCoordinatorBridgePresenter.swift +++ b/Riot/Modules/Secrets/Recover/SecretsRecoveryCoordinatorBridgePresenter.swift @@ -91,7 +91,7 @@ final class SecretsRecoveryCoordinatorBridgePresenter: NSObject { return } - NSLog("[SecretsRecoveryCoordinatorBridgePresenter] Dismiss") + MXLog.debug("[SecretsRecoveryCoordinatorBridgePresenter] Dismiss") coordinator.toPresentable().dismiss(animated: animated) { self.coordinator = nil diff --git a/Riot/Modules/Secrets/Reset/SecretsResetViewModel.swift b/Riot/Modules/Secrets/Reset/SecretsResetViewModel.swift index 8a122b23c..05b691f3a 100644 --- a/Riot/Modules/Secrets/Reset/SecretsResetViewModel.swift +++ b/Riot/Modules/Secrets/Reset/SecretsResetViewModel.swift @@ -66,7 +66,7 @@ final class SecretsResetViewModel: SecretsResetViewModelType { guard let crossSigning = self.session.crypto.crossSigning else { return } - NSLog("[SecretsResetViewModel] resetSecrets") + MXLog.debug("[SecretsResetViewModel] resetSecrets") self.update(viewState: .resetting) crossSigning.setup(withAuthParams: authParameters, success: { [weak self] in diff --git a/Riot/Modules/ServiceTerms/Modal/Modal/ServiceTermsModalScreenViewModel.swift b/Riot/Modules/ServiceTerms/Modal/Modal/ServiceTermsModalScreenViewModel.swift index 87cfc3a92..a49d6954f 100644 --- a/Riot/Modules/ServiceTerms/Modal/Modal/ServiceTermsModalScreenViewModel.swift +++ b/Riot/Modules/ServiceTerms/Modal/Modal/ServiceTermsModalScreenViewModel.swift @@ -114,7 +114,7 @@ final class ServiceTermsModalScreenViewModel: ServiceTermsModalScreenViewModelTy if let policies = terms?.policiesData(forLanguage: Bundle.mxk_language(), defaultLanguage: Bundle.mxk_fallbackLanguage()) { return policies } else { - print("[ServiceTermsModalScreenViewModel] processTerms: Error: No terms for \(String(describing: terms))") + MXLog.debug("[ServiceTermsModalScreenViewModel] processTerms: Error: No terms for \(String(describing: terms))") return [] } } diff --git a/Riot/Modules/SetPinCode/PinCodePreferences.swift b/Riot/Modules/SetPinCode/PinCodePreferences.swift index 8a8c86521..386dc26a0 100644 --- a/Riot/Modules/SetPinCode/PinCodePreferences.swift +++ b/Riot/Modules/SetPinCode/PinCodePreferences.swift @@ -17,6 +17,7 @@ limitations under the License. import Foundation import KeychainAccess import LocalAuthentication +import MatrixSDK /// Pin code preferences. @objcMembers @@ -95,14 +96,14 @@ final class PinCodePreferences: NSObject { do { return try store.string(forKey: StoreKeys.pin) } catch let error { - NSLog("[PinCodePreferences] Error when reading user pin from store: \(error)") + MXLog.debug("[PinCodePreferences] Error when reading user pin from store: \(error)") return nil } } set { do { try store.set(newValue, forKey: StoreKeys.pin) } catch let error { - NSLog("[PinCodePreferences] Error when storing user pin to the store: \(error)") + MXLog.debug("[PinCodePreferences] Error when storing user pin to the store: \(error)") } } } @@ -112,14 +113,14 @@ final class PinCodePreferences: NSObject { do { return try store.bool(forKey: StoreKeys.biometricsEnabled) } catch let error { - NSLog("[PinCodePreferences] Error when reading biometrics enabled from store: \(error)") + MXLog.debug("[PinCodePreferences] Error when reading biometrics enabled from store: \(error)") return nil } } set { do { try store.set(newValue, forKey: StoreKeys.biometricsEnabled) } catch let error { - NSLog("[PinCodePreferences] Error when storing biometrics enabled to the store: \(error)") + MXLog.debug("[PinCodePreferences] Error when storing biometrics enabled to the store: \(error)") } } } @@ -129,14 +130,14 @@ final class PinCodePreferences: NSObject { do { return try store.bool(forKey: StoreKeys.canUseBiometricsToUnlock) } catch let error { - NSLog("[PinCodePreferences] Error when reading canUseBiometricsToUnlock from store: \(error)") + MXLog.debug("[PinCodePreferences] Error when reading canUseBiometricsToUnlock from store: \(error)") return nil } } set { do { try store.set(newValue, forKey: StoreKeys.canUseBiometricsToUnlock) } catch let error { - NSLog("[PinCodePreferences] Error when storing canUseBiometricsToUnlock to the store: \(error)") + MXLog.debug("[PinCodePreferences] Error when storing canUseBiometricsToUnlock to the store: \(error)") } } } @@ -146,14 +147,14 @@ final class PinCodePreferences: NSObject { do { return try store.integer(forKey: StoreKeys.numberOfPinFailures) ?? 0 } catch let error { - NSLog("[PinCodePreferences] Error when reading numberOfPinFailures from store: \(error)") + MXLog.debug("[PinCodePreferences] Error when reading numberOfPinFailures from store: \(error)") return 0 } } set { do { try store.set(newValue, forKey: StoreKeys.numberOfPinFailures) } catch let error { - NSLog("[PinCodePreferences] Error when storing numberOfPinFailures to the store: \(error)") + MXLog.debug("[PinCodePreferences] Error when storing numberOfPinFailures to the store: \(error)") } } } @@ -163,14 +164,14 @@ final class PinCodePreferences: NSObject { do { return try store.integer(forKey: StoreKeys.numberOfBiometricsFailures) ?? 0 } catch let error { - NSLog("[PinCodePreferences] Error when reading numberOfBiometricsFailures from store: \(error)") + MXLog.debug("[PinCodePreferences] Error when reading numberOfBiometricsFailures from store: \(error)") return 0 } } set { do { try store.set(newValue, forKey: StoreKeys.numberOfBiometricsFailures) } catch let error { - NSLog("[PinCodePreferences] Error when storing numberOfBiometricsFailures to the store: \(error)") + MXLog.debug("[PinCodePreferences] Error when storing numberOfBiometricsFailures to the store: \(error)") } } } diff --git a/Riot/Modules/Settings/DeactivateAccount/DeactivateAccountViewController.m b/Riot/Modules/Settings/DeactivateAccount/DeactivateAccountViewController.m index c7568e7f8..0c93b1873 100644 --- a/Riot/Modules/Settings/DeactivateAccount/DeactivateAccountViewController.m +++ b/Riot/Modules/Settings/DeactivateAccount/DeactivateAccountViewController.m @@ -279,7 +279,7 @@ static CGFloat const kTextFontSize = 15.0; @"type": kMXLoginFlowTypePassword}; [self.mainSession deactivateAccountWithAuthParameters:authParameters eraseAccount:eraseAllMessages success:^{ - NSLog(@"[SettingsViewController] Deactivate account with success"); + MXLogDebug(@"[SettingsViewController] Deactivate account with success"); typeof(weakSelf) strongSelf = weakSelf; @@ -292,7 +292,7 @@ static CGFloat const kTextFontSize = 15.0; } failure:^(NSError *error) { - NSLog(@"[SettingsViewController] Failed to deactivate account"); + MXLogDebug(@"[SettingsViewController] Failed to deactivate account"); typeof(weakSelf) strongSelf = weakSelf; @@ -306,7 +306,7 @@ static CGFloat const kTextFontSize = 15.0; } else { - NSLog(@"[SettingsViewController] Failed to deactivate account"); + MXLogDebug(@"[SettingsViewController] Failed to deactivate account"); [self.errorPresentation presentGenericErrorFromViewController:self animated:YES handler:nil]; } } diff --git a/Riot/Modules/Settings/IdentityServer/SettingsIdentityServerViewModel.swift b/Riot/Modules/Settings/IdentityServer/SettingsIdentityServerViewModel.swift index 976da339c..0c80415fb 100644 --- a/Riot/Modules/Settings/IdentityServer/SettingsIdentityServerViewModel.swift +++ b/Riot/Modules/Settings/IdentityServer/SettingsIdentityServerViewModel.swift @@ -96,7 +96,7 @@ final class SettingsIdentityServerViewModel: SettingsIdentityServerViewModelType viewStateUpdate(.loading) self.checkIdentityServerValidity(identityServer: newIdentityServer) { (identityServerValidityResponse) in - print("[SettingsIdentityServerViewModel] checkCanAddIdentityServer: \(newIdentityServer). Validity: \(identityServerValidityResponse)") + MXLog.debug("[SettingsIdentityServerViewModel] checkCanAddIdentityServer: \(newIdentityServer). Validity: \(identityServerValidityResponse)") switch identityServerValidityResponse { case .success(let identityServerValidity): @@ -119,7 +119,7 @@ final class SettingsIdentityServerViewModel: SettingsIdentityServerViewModelType switch response { case .success(let accessToken): guard let accessToken = accessToken else { - print("[SettingsIdentityServerViewModel] accessToken: Error: No access token") + MXLog.debug("[SettingsIdentityServerViewModel] accessToken: Error: No access token") viewStateUpdate(.error(SettingsIdentityServerViewModelError.unknown)) return } diff --git a/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m b/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m index a921b6dc4..fd2b37f36 100644 --- a/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m +++ b/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m @@ -244,7 +244,7 @@ enum { completion(); } failure:^(NSError *error) { - NSLog(@"[ManageSessionVC] reloadDeviceWithCompletion failed. Error: %@", error); + MXLogDebug(@"[ManageSessionVC] reloadDeviceWithCompletion failed. Error: %@", error); [self reloadData]; completion(); }]; @@ -652,7 +652,7 @@ enum { }]; } failure:^(NSError *error) { - NSLog(@"[ManageSessionVC] Rename device (%@) failed", self->device.deviceId); + MXLogDebug(@"[ManageSessionVC] Rename device (%@) failed", self->device.deviceId); [self reloadDeviceWithCompletion:^{ [self.activityIndicator stopAnimating]; [[AppDelegate theDelegate] showErrorAsAlert:error]; @@ -709,7 +709,7 @@ enum { // We cannot stay in this screen anymore [self withdrawViewControllerAnimated:YES completion:nil]; } failure:^(NSError *error) { - NSLog(@"[ManageSessionVC] Delete device (%@) failed", self->device.deviceId); + MXLogDebug(@"[ManageSessionVC] Delete device (%@) failed", self->device.deviceId); animationCompletion(); [[AppDelegate theDelegate] showErrorAsAlert:error]; }]; diff --git a/Riot/Modules/Settings/Security/SecurityViewController.m b/Riot/Modules/Settings/Security/SecurityViewController.m index c087bdfb6..5817a6816 100644 --- a/Riot/Modules/Settings/Security/SecurityViewController.m +++ b/Riot/Modules/Settings/Security/SecurityViewController.m @@ -652,7 +652,7 @@ TableViewSectionsDelegate> [self reloadData]; } } failure:^(NSError * _Nonnull error) { - NSLog(@"[SecurityVC] loadCrossSigning: Cannot refresh cross-signing state. Error: %@", error); + MXLogDebug(@"[SecurityVC] loadCrossSigning: Cannot refresh cross-signing state. Error: %@", error); }]; } diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index 423a2d4c7..5f6acbefd 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -955,12 +955,12 @@ TableViewSectionsDelegate> } } failure:^(NSError * _Nonnull error) { - NSLog(@"[SettingsViewController] tryFinaliseAddEmailSession: Failed to bind email"); + MXLogDebug(@"[SettingsViewController] tryFinaliseAddEmailSession: Failed to bind email"); MXError *mxError = [[MXError alloc] initWithNSError:error]; if (mxError && [mxError.errcode isEqualToString:kMXErrCodeStringForbidden]) { - NSLog(@"[SettingsViewController] tryFinaliseAddEmailSession: Wrong credentials"); + MXLogDebug(@"[SettingsViewController] tryFinaliseAddEmailSession: Wrong credentials"); // Ask password again self->currentAlert = [UIAlertController alertControllerWithTitle:nil @@ -1086,12 +1086,12 @@ TableViewSectionsDelegate> } failure:^(NSError * _Nonnull error) { - NSLog(@"[SettingsViewController] finaliseAddPhoneNumberSession: Failed to submit the sms token"); + MXLogDebug(@"[SettingsViewController] finaliseAddPhoneNumberSession: Failed to submit the sms token"); MXError *mxError = [[MXError alloc] initWithNSError:error]; if (mxError && [mxError.errcode isEqualToString:kMXErrCodeStringForbidden]) { - NSLog(@"[SettingsViewController] finaliseAddPhoneNumberSession: Wrong authentication credentials"); + MXLogDebug(@"[SettingsViewController] finaliseAddPhoneNumberSession: Wrong authentication credentials"); // Ask password again self->currentAlert = [UIAlertController alertControllerWithTitle:nil @@ -2536,7 +2536,7 @@ TableViewSectionsDelegate> [self stopActivityIndicator]; - NSLog(@"[SettingsViewController] Unignore %@ failed", ignoredUserId); + MXLogDebug(@"[SettingsViewController] Unignore %@ failed", ignoredUserId); NSString *myUserId = session.myUser.userId; [[NSNotificationCenter defaultCenter] postNotificationName:kMXKErrorNotification object:error userInfo:myUserId ? @{kMXKErrorUserIdKey: myUserId} : nil]; @@ -2768,7 +2768,7 @@ TableViewSectionsDelegate> } failure:^(NSError *error) { - NSLog(@"[SettingsViewController] Remove 3PID: %@ failed", address); + MXLogDebug(@"[SettingsViewController] Remove 3PID: %@ failed", address); if (weakSelf) { typeof(self) self = weakSelf; @@ -2922,7 +2922,7 @@ TableViewSectionsDelegate> BOOL enable = RiotSettings.shared.enableCrashReport; if (enable) { - NSLog(@"[SettingsViewController] disable automatic crash report and analytics sending"); + MXLogDebug(@"[SettingsViewController] disable automatic crash report and analytics sending"); RiotSettings.shared.enableCrashReport = NO; @@ -2933,7 +2933,7 @@ TableViewSectionsDelegate> } else { - NSLog(@"[SettingsViewController] enable automatic crash report and analytics sending"); + MXLogDebug(@"[SettingsViewController] enable automatic crash report and analytics sending"); RiotSettings.shared.enableCrashReport = YES; @@ -3101,7 +3101,7 @@ TableViewSectionsDelegate> } failure:^(NSError *error) { - NSLog(@"[SettingsViewController] Failed to set displayName"); + MXLogDebug(@"[SettingsViewController] Failed to set displayName"); if (weakSelf) { @@ -3137,7 +3137,7 @@ TableViewSectionsDelegate> } failure:^(NSError *error) { - NSLog(@"[SettingsViewController] Failed to upload image"); + MXLogDebug(@"[SettingsViewController] Failed to upload image"); if (weakSelf) { @@ -3164,7 +3164,7 @@ TableViewSectionsDelegate> } failure:^(NSError *error) { - NSLog(@"[SettingsViewController] Failed to set avatar url"); + MXLogDebug(@"[SettingsViewController] Failed to set avatar url"); if (weakSelf) { @@ -3316,7 +3316,7 @@ TableViewSectionsDelegate> [self stopActivityIndicator]; - NSLog(@"[SettingsViewController] Failed to request email token"); + MXLogDebug(@"[SettingsViewController] Failed to request email token"); // Translate the potential MX error. MXError *mxError = [[MXError alloc] initWithNSError:error]; @@ -3431,7 +3431,7 @@ TableViewSectionsDelegate> [self stopActivityIndicator]; - NSLog(@"[SettingsViewController] Failed to request msisdn token"); + MXLogDebug(@"[SettingsViewController] Failed to request msisdn token"); // Translate the potential MX error. MXError *mxError = [[MXError alloc] initWithNSError:error]; @@ -3982,10 +3982,10 @@ TableViewSectionsDelegate> - (void)deactivateAccountViewControllerDidDeactivateWithSuccess:(DeactivateAccountViewController *)deactivateAccountViewController { - NSLog(@"[SettingsViewController] Deactivate account with success"); + MXLogDebug(@"[SettingsViewController] Deactivate account with success"); [[AppDelegate theDelegate] logoutSendingRequestServer:NO completion:^(BOOL isLoggedOut) { - NSLog(@"[SettingsViewController] Complete clear user data after account deactivation"); + MXLogDebug(@"[SettingsViewController] Complete clear user data after account deactivation"); }]; } diff --git a/Riot/Modules/SlidingModal/SlidingModalPresenter.swift b/Riot/Modules/SlidingModal/SlidingModalPresenter.swift index 4b4e3b663..55bd7873b 100644 --- a/Riot/Modules/SlidingModal/SlidingModalPresenter.swift +++ b/Riot/Modules/SlidingModal/SlidingModalPresenter.swift @@ -62,7 +62,7 @@ final class SlidingModalPresenter: NSObject { func present(_ viewController: SlidingModalPresentable.ViewControllerType, from presentingViewController: UIViewController, animated: Bool, options: SlidingModalOption, completion: (() -> Void)?) { - NSLog("[SlidingModalPresenter] present \(type(of: viewController))") + MXLog.debug("[SlidingModalPresenter] present \(type(of: viewController))") let transitionDelegate = SlidingModalPresentationDelegate(isSpanning: options.contains(.spanning), blurBackground: options.contains(.blurBackground)) @@ -81,7 +81,7 @@ final class SlidingModalPresenter: NSObject { @objc func presentView(_ view: SlidingModalPresentable.ViewType, from viewControllerPresenter: UIViewController, animated: Bool, completion: (() -> Void)?) { - NSLog("[SlidingModalPresenter] presentView \(type(of: view))") + MXLog.debug("[SlidingModalPresenter] presentView \(type(of: view))") let viewController = SlidingModalEmptyViewController.instantiate(with: view) self.present(viewController, from: viewControllerPresenter, animated: animated, completion: completion) diff --git a/Riot/Modules/SplitView/SplitViewCoordinator.swift b/Riot/Modules/SplitView/SplitViewCoordinator.swift index c03cf2cec..b21353cb6 100644 --- a/Riot/Modules/SplitView/SplitViewCoordinator.swift +++ b/Riot/Modules/SplitView/SplitViewCoordinator.swift @@ -169,10 +169,10 @@ extension SplitViewCoordinator: TabBarCoordinatorDelegate { /// MARK: - SplitViewMasterPresentableDelegate extension SplitViewCoordinator: SplitViewMasterPresentableDelegate { func splitViewMasterPresentable(_ presentable: Presentable, wantsToDisplay detailPresentable: Presentable) { - NSLog("[SplitViewCoordinator] splitViewMasterPresentable: \(presentable) wantsToDisplay detailPresentable: \(detailPresentable)") + MXLog.debug("[SplitViewCoordinator] splitViewMasterPresentable: \(presentable) wantsToDisplay detailPresentable: \(detailPresentable)") guard let detailNavigationController = self.detailNavigationController else { - NSLog("[SplitViewCoordinator] splitViewMasterPresentable: Failed to display because detailNavigationController is nil") + MXLog.debug("[SplitViewCoordinator] splitViewMasterPresentable: Failed to display because detailNavigationController is nil") return } diff --git a/Riot/Modules/StartChat/StartChatViewController.m b/Riot/Modules/StartChat/StartChatViewController.m index 421ac343e..00b881568 100644 --- a/Riot/Modules/StartChat/StartChatViewController.m +++ b/Riot/Modules/StartChat/StartChatViewController.m @@ -570,7 +570,7 @@ // The identity server must be defined if (!self.mainSession.matrixRestClient.identityServer) { - NSLog(@"[StartChatViewController] Invite %@ failed", participantId); + MXLogDebug(@"[StartChatViewController] Invite %@ failed", participantId); continue; } @@ -622,7 +622,7 @@ self->roomCreationRequest = nil; [self stopActivityIndicator]; - NSLog(@"[StartChatViewController] Create room failed"); + MXLogDebug(@"[StartChatViewController] Create room failed"); // Alert user [[AppDelegate theDelegate] showErrorAsAlert:error]; @@ -754,7 +754,7 @@ if ([MXTools isEmailAddress:participantId]) { - NSLog(@"[StartChatViewController] No identity server is configured, do not add participant with email"); + MXLogDebug(@"[StartChatViewController] No identity server is configured, do not add participant with email"); [contactsTableViewController refreshCurrentSelectedCell:YES]; diff --git a/Riot/Modules/TabBar/MasterTabBarController.m b/Riot/Modules/TabBar/MasterTabBarController.m index 215409ddd..501ece829 100644 --- a/Riot/Modules/TabBar/MasterTabBarController.m +++ b/Riot/Modules/TabBar/MasterTabBarController.m @@ -155,7 +155,7 @@ - (void)viewDidAppear:(BOOL)animated { - NSLog(@"[MasterTabBarController] viewDidAppear"); + MXLogDebug(@"[MasterTabBarController] viewDidAppear"); [super viewDidAppear:animated]; // Check whether we're not logged in @@ -295,7 +295,7 @@ if (mainSession) { - NSLog(@"[MasterTabBarController] initializeDataSources"); + MXLogDebug(@"[MasterTabBarController] initializeDataSources"); // Init the recents data source recentsDataSource = [[RecentsDataSource alloc] initWithMatrixSession:mainSession]; @@ -470,7 +470,7 @@ - (void)showAuthenticationScreen { - NSLog(@"[MasterTabBarController] showAuthenticationScreen"); + MXLogDebug(@"[MasterTabBarController] showAuthenticationScreen"); // Check whether an authentication screen is not already shown or preparing if (!self.authViewController && !isAuthViewControllerPreparing) @@ -491,12 +491,12 @@ { if (self.authViewController) { - NSLog(@"[MasterTabBarController] Universal link: Forward registration parameter to the existing AuthViewController"); + MXLogDebug(@"[MasterTabBarController] Universal link: Forward registration parameter to the existing AuthViewController"); self.authViewController.externalRegistrationParameters = parameters; } else { - NSLog(@"[MasterTabBarController] Universal link: Prompt to logout current sessions and open AuthViewController to complete the registration"); + MXLogDebug(@"[MasterTabBarController] Universal link: Prompt to logout current sessions and open AuthViewController to complete the registration"); // Keep a ref on the params authViewControllerRegistrationParameters = parameters; @@ -514,7 +514,7 @@ - (void)showAuthenticationScreenAfterSoftLogout:(MXCredentials*)credentials; { - NSLog(@"[MasterTabBarController] showAuthenticationScreenAfterSoftLogout"); + MXLogDebug(@"[MasterTabBarController] showAuthenticationScreenAfterSoftLogout"); softLogoutCredentials = credentials; @@ -1018,7 +1018,7 @@ - (void)promptUserBeforeUsingAnalytics { - NSLog(@"[MasterTabBarController]: Invite the user to send crash reports"); + MXLogDebug(@"[MasterTabBarController]: Invite the user to send crash reports"); __weak typeof(self) weakSelf = self; @@ -1079,7 +1079,7 @@ - (void)presentVerifyCurrentSessionAlertWithSession:(MXSession*)session { - NSLog(@"[MasterTabBarController] presentVerifyCurrentSessionAlertWithSession"); + MXLogDebug(@"[MasterTabBarController] presentVerifyCurrentSessionAlertWithSession"); [currentAlert dismissViewControllerAnimated:NO completion:nil]; @@ -1138,7 +1138,7 @@ - (void)presentReviewUnverifiedSessionsAlertWithSession:(MXSession*)session { - NSLog(@"[MasterTabBarController] presentReviewUnverifiedSessionsAlertWithSession"); + MXLogDebug(@"[MasterTabBarController] presentReviewUnverifiedSessionsAlertWithSession"); [currentAlert dismissViewControllerAnimated:NO completion:nil]; diff --git a/Riot/Modules/TabBar/TabBarCoordinator.swift b/Riot/Modules/TabBar/TabBarCoordinator.swift index 0cd2a488c..823d7f505 100644 --- a/Riot/Modules/TabBar/TabBarCoordinator.swift +++ b/Riot/Modules/TabBar/TabBarCoordinator.swift @@ -294,7 +294,7 @@ final class TabBarCoordinator: NSObject, TabBarCoordinatorType { guard self.masterTabBarController.mxSessions.contains(matrixSession) == false else { return } - NSLog("[TabBarCoordinator] masterTabBarController.addMatrixSession") + MXLog.debug("[TabBarCoordinator] masterTabBarController.addMatrixSession") self.masterTabBarController.addMatrixSession(matrixSession) } @@ -303,7 +303,7 @@ final class TabBarCoordinator: NSObject, TabBarCoordinatorType { guard self.masterTabBarController.mxSessions.contains(matrixSession) else { return } - NSLog("[TabBarCoordinator] masterTabBarController.removeMatrixSession") + MXLog.debug("[TabBarCoordinator] masterTabBarController.removeMatrixSession") self.masterTabBarController.removeMatrixSession(matrixSession) } } diff --git a/Riot/Modules/UserDevices/Views/DeviceTableViewCell.m b/Riot/Modules/UserDevices/Views/DeviceTableViewCell.m index 41bf6485f..af66909b8 100644 --- a/Riot/Modules/UserDevices/Views/DeviceTableViewCell.m +++ b/Riot/Modules/UserDevices/Views/DeviceTableViewCell.m @@ -119,7 +119,7 @@ else { // Unexpected case - NSLog(@"[DeviceTableViewCell] Invalid button pressed."); + MXLogDebug(@"[DeviceTableViewCell] Invalid button pressed."); return; } diff --git a/Riot/Routers/NavigationRouter.swift b/Riot/Routers/NavigationRouter.swift index 411cdf390..ff51b29df 100755 --- a/Riot/Routers/NavigationRouter.swift +++ b/Riot/Routers/NavigationRouter.swift @@ -44,17 +44,17 @@ final class NavigationRouter: NSObject, NavigationRouterType { // MARK: - Public func present(_ module: Presentable, animated: Bool = true) { - NSLog("[NavigationRouter] Present \(module)") + MXLog.debug("[NavigationRouter] Present \(module)") navigationController.present(module.toPresentable(), animated: animated, completion: nil) } func dismissModule(animated: Bool = true, completion: (() -> Void)? = nil) { - NSLog("[NavigationRouter] Dismiss presented module") + MXLog.debug("[NavigationRouter] Dismiss presented module") navigationController.dismiss(animated: animated, completion: completion) } func setRootModule(_ module: Presentable, hideNavigationBar: Bool = false, animated: Bool = false, popCompletion: (() -> Void)? = nil) { - NSLog("[NavigationRouter] Set root module \(module)") + MXLog.debug("[NavigationRouter] Set root module \(module)") let controller = module.toPresentable() @@ -77,7 +77,7 @@ final class NavigationRouter: NSObject, NavigationRouterType { } func popToRootModule(animated: Bool) { - NSLog("[NavigationRouter] Pop to root module") + MXLog.debug("[NavigationRouter] Pop to root module") if let controllers = navigationController.popToRootViewController(animated: animated) { controllers.forEach { runCompletion(for: $0) } @@ -85,7 +85,7 @@ final class NavigationRouter: NSObject, NavigationRouterType { } func popToModule(_ module: Presentable, animated: Bool) { - NSLog("[NavigationRouter] Pop to module \(module)") + MXLog.debug("[NavigationRouter] Pop to module \(module)") if let controllers = navigationController.popToViewController(module.toPresentable(), animated: animated) { controllers.forEach { runCompletion(for: $0) } @@ -93,7 +93,7 @@ final class NavigationRouter: NSObject, NavigationRouterType { } func push(_ module: Presentable, animated: Bool = true, popCompletion: (() -> Void)? = nil) { - NSLog("[NavigationRouter] Push module \(module)") + MXLog.debug("[NavigationRouter] Push module \(module)") let controller = module.toPresentable() @@ -110,7 +110,7 @@ final class NavigationRouter: NSObject, NavigationRouterType { } func popModule(animated: Bool = true) { - NSLog("[NavigationRouter] Pop module") + MXLog.debug("[NavigationRouter] Pop module") if let controller = navigationController.popViewController(animated: animated) { runCompletion(for: controller) @@ -145,7 +145,7 @@ extension NavigationRouter: UINavigationControllerDelegate { return } - NSLog("[NavigationRouter] Poppped module: \(poppedViewController)") + MXLog.debug("[NavigationRouter] Poppped module: \(poppedViewController)") runCompletion(for: poppedViewController) } diff --git a/Riot/target.yml b/Riot/target.yml index 7a0d46b75..b22965c42 100644 --- a/Riot/target.yml +++ b/Riot/target.yml @@ -44,11 +44,11 @@ targets: - name: ⚠️ SwiftLint runOnlyWhenInstalling: false shell: /bin/sh - script: "${PODS_ROOT}/SwiftLint/swiftlint\n" + script: "\"${PODS_ROOT}/SwiftLint/swiftlint\"\n" - name: 🛠 SwiftGen runOnlyWhenInstalling: false shell: /bin/sh - script: "${PODS_ROOT}/SwiftGen/bin/swiftgen config run --config Tools/SwiftGen/swiftgen-config.yml\n" + script: "\"${PODS_ROOT}/SwiftGen/bin/swiftgen\" config run --config \"Tools/SwiftGen/swiftgen-config.yml\"\n" sources: - path: ../Tools diff --git a/RiotNSE/NotificationService.swift b/RiotNSE/NotificationService.swift index 82fcda16e..3ac8cd0bd 100644 --- a/RiotNSE/NotificationService.swift +++ b/RiotNSE/NotificationService.swift @@ -77,11 +77,11 @@ class NotificationService: UNNotificationServiceExtension { // setup logs setupLogger() - NSLog(" ") - NSLog(" ") - NSLog("################################################################################") - NSLog("[NotificationService] Instance: \(self), thread: \(Thread.current)") - NSLog("[NotificationService] Payload came: \(userInfo)") + MXLog.debug(" ") + MXLog.debug(" ") + MXLog.debug("################################################################################") + MXLog.debug("[NotificationService] Instance: \(self), thread: \(Thread.current)") + MXLog.debug("[NotificationService] Payload came: \(userInfo)") // log memory at the beginning of the process logMemory() @@ -91,7 +91,7 @@ class NotificationService: UNNotificationServiceExtension { // check if this is a Matrix notification guard let roomId = userInfo["room_id"] as? String, let eventId = userInfo["event_id"] as? String else { // it's not a Matrix notification, do not change the content - NSLog("[NotificationService] didReceiveRequest: This is not a Matrix notification.") + MXLog.debug("[NotificationService] didReceiveRequest: This is not a Matrix notification.") contentHandler(request.content) return } @@ -124,30 +124,37 @@ class NotificationService: UNNotificationServiceExtension { // Called just before the extension will be terminated by the system. // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used. - NSLog("[NotificationService] serviceExtensionTimeWillExpire") + MXLog.debug("[NotificationService] serviceExtensionTimeWillExpire") // No-op here. If the process is killed by the OS due to time limit, it will also show the notification with the original content. } deinit { - NSLog("[NotificationService] deinit for \(self)"); + MXLog.debug("[NotificationService] deinit for \(self)"); self.logMemory() - NSLog(" ") + MXLog.debug(" ") } // MARK: - Private private func logMemory() { - NSLog("[NotificationService] Memory: footprint: \(MXMemory.formattedMemoryFootprint()) - available: \(MXMemory.formattedMemoryAvailable())") + MXLog.debug("[NotificationService] Memory: footprint: \(MXMemory.formattedMemoryFootprint()) - available: \(MXMemory.formattedMemoryAvailable())") } private func setupLogger() { if !NotificationService.isLoggerInitialized { + let configuration = MXLogConfiguration() + configuration.logLevel = .verbose + configuration.maxLogFilesCount = 100 + configuration.logFilesSizeLimit = 10 * 1024 * 1024; // 10MB + configuration.subLogName = "nse" + if isatty(STDERR_FILENO) == 0 { - MXLogger.setSubLogName("nse") - let sizeLimit: UInt = 10 * 1024 * 1024; // 10MB - MXLogger.redirectNSLog(toFiles: true, numberOfFiles: 100, sizeLimit: sizeLimit) + configuration.redirectLogsToFiles = true } + + MXLog.configure(configuration) + NotificationService.isLoggerInitialized = true } } @@ -157,15 +164,15 @@ class NotificationService: UNNotificationServiceExtension { self.userAccount = MXKAccountManager.shared()?.activeAccounts.first if let userAccount = userAccount { if NotificationService.backgroundSyncService == nil { - NSLog("[NotificationService] setup: MXBackgroundSyncService init: BEFORE") + MXLog.debug("[NotificationService] setup: MXBackgroundSyncService init: BEFORE") self.logMemory() NotificationService.backgroundSyncService = MXBackgroundSyncService(withCredentials: userAccount.mxCredentials) - NSLog("[NotificationService] setup: MXBackgroundSyncService init: AFTER") + MXLog.debug("[NotificationService] setup: MXBackgroundSyncService init: AFTER") self.logMemory() } completion() } else { - NSLog("[NotificationService] setup: No active accounts") + MXLog.debug("[NotificationService] setup: No active accounts") fallbackToBestAttemptContent(forEventId: eventId) } } @@ -176,7 +183,7 @@ class NotificationService: UNNotificationServiceExtension { /// - roomId: Room identifier to fetch display name private func preprocessPayload(forEventId eventId: String, roomId: String) { if localAuthenticationService.isProtectionSet { - NSLog("[NotificationService] preprocessPayload: Do not preprocess because app protection is set") + MXLog.debug("[NotificationService] preprocessPayload: Do not preprocess because app protection is set") return } guard let roomSummary = NotificationService.backgroundSyncService.roomSummary(forRoomId: roomId) else { return } @@ -189,17 +196,17 @@ class NotificationService: UNNotificationServiceExtension { } private func fetchEvent(withEventId eventId: String, roomId: String, allowSync: Bool = true) { - NSLog("[NotificationService] fetchEvent") + MXLog.debug("[NotificationService] fetchEvent") NotificationService.backgroundSyncService.event(withEventId: eventId, inRoom: roomId, completion: { (response) in switch response { case .success(let event): - NSLog("[NotificationService] fetchEvent: Event fetched successfully") + MXLog.debug("[NotificationService] fetchEvent: Event fetched successfully") self.processEvent(event) case .failure(let error): - NSLog("[NotificationService] fetchEvent: error: \(error)") + MXLog.debug("[NotificationService] fetchEvent: error: \(error)") self.fallbackToBestAttemptContent(forEventId: eventId) } }) @@ -207,7 +214,7 @@ class NotificationService: UNNotificationServiceExtension { private func processEvent(_ event: MXEvent) { if let receiveDate = receiveDates[event.eventId] { - NSLog("[NotificationService] processEvent: notification receive delay: \(receiveDate.timeIntervalSince1970*MSEC_PER_SEC - TimeInterval(event.originServerTs)) ms") + MXLog.debug("[NotificationService] processEvent: notification receive delay: \(receiveDate.timeIntervalSince1970*MSEC_PER_SEC - TimeInterval(event.originServerTs)) ms") } guard let content = bestAttemptContents[event.eventId], let userAccount = userAccount else { @@ -241,23 +248,23 @@ class NotificationService: UNNotificationServiceExtension { // When it completes, it'll continue with the bestAttemptContent. return } else { - NSLog("[NotificationService] processEvent: Calling content handler for: \(String(describing: event.eventId)), isUnwanted: \(isUnwantedNotification)") + MXLog.debug("[NotificationService] processEvent: Calling content handler for: \(String(describing: event.eventId)), isUnwanted: \(isUnwantedNotification)") self.contentHandlers[event.eventId]?(content) // clear maps self.contentHandlers.removeValue(forKey: event.eventId) self.bestAttemptContents.removeValue(forKey: event.eventId) // We are done for this push - NSLog("--------------------------------------------------------------------------------") + MXLog.debug("--------------------------------------------------------------------------------") } } } private func fallbackToBestAttemptContent(forEventId eventId: String) { - NSLog("[NotificationService] fallbackToBestAttemptContent: method called.") + MXLog.debug("[NotificationService] fallbackToBestAttemptContent: method called.") guard let content = bestAttemptContents[eventId] else { - NSLog("[NotificationService] fallbackToBestAttemptContent: Best attempt content is missing.") + MXLog.debug("[NotificationService] fallbackToBestAttemptContent: Best attempt content is missing.") return } @@ -269,12 +276,12 @@ class NotificationService: UNNotificationServiceExtension { receiveDates.removeValue(forKey: eventId) // We are done for this push - NSLog("--------------------------------------------------------------------------------") + MXLog.debug("--------------------------------------------------------------------------------") } private func notificationContent(forEvent event: MXEvent, forAccount account: MXKAccount, onComplete: @escaping (UNNotificationContent?) -> Void) { guard let content = event.content, content.count > 0 else { - NSLog("[NotificationService] notificationContentForEvent: empty event content") + MXLog.debug("[NotificationService] notificationContentForEvent: empty event content") onComplete(nil) return } @@ -283,7 +290,7 @@ class NotificationService: UNNotificationServiceExtension { let isRoomMentionsOnly = NotificationService.backgroundSyncService.isRoomMentionsOnly(roomId) let roomSummary = NotificationService.backgroundSyncService.roomSummary(forRoomId: roomId) - NSLog("[NotificationService] notificationContentForEvent: Attempt to fetch the room state") + MXLog.debug("[NotificationService] notificationContentForEvent: Attempt to fetch the room state") self.context(ofEvent: event, inRoom: roomId, completion: { (response) in switch response { @@ -317,7 +324,7 @@ class NotificationService: UNNotificationServiceExtension { (callInviteContent.lifetime - event.age) > UInt(NSE.Constants.timeNeededToSendVoIPPushes * MSEC_PER_SEC) { self.sendVoipPush(forEvent: event) } else { - NSLog("[NotificationService] notificationContent: Do not attempt to send a VoIP push, there is not enough time to process it.") + MXLog.debug("[NotificationService] notificationContent: Do not attempt to send a VoIP push, there is not enough time to process it.") } case .roomMessage, .roomEncrypted: if isRoomMentionsOnly { @@ -339,7 +346,7 @@ class NotificationService: UNNotificationServiceExtension { if !isHighlighted { // Ignore this notif. - NSLog("[NotificationService] notificationContentForEvent: Ignore non highlighted notif in mentions only room") + MXLog.debug("[NotificationService] notificationContentForEvent: Ignore non highlighted notif in mentions only room") onComplete(nil) return } @@ -422,13 +429,13 @@ class NotificationService: UNNotificationServiceExtension { } if self.localAuthenticationService.isProtectionSet { - NSLog("[NotificationService] notificationContentForEvent: Resetting title and body because app protection is set") + MXLog.debug("[NotificationService] notificationContentForEvent: Resetting title and body because app protection is set") notificationBody = NSString.localizedUserNotificationString(forKey: "MESSAGE_PROTECTED", arguments: []) notificationTitle = nil } guard notificationBody != nil else { - NSLog("[NotificationService] notificationContentForEvent: notificationBody is nil") + MXLog.debug("[NotificationService] notificationContentForEvent: notificationBody is nil") onComplete(nil) return } @@ -441,10 +448,10 @@ class NotificationService: UNNotificationServiceExtension { pushRule: pushRule, additionalInfo: additionalUserInfo) - NSLog("[NotificationService] notificationContentForEvent: Calling onComplete.") + MXLog.debug("[NotificationService] notificationContentForEvent: Calling onComplete.") onComplete(notificationContent) case .failure(let error): - NSLog("[NotificationService] notificationContentForEvent: error: \(error)") + MXLog.debug("[NotificationService] notificationContentForEvent: error: \(error)") onComplete(nil) } }) @@ -556,7 +563,7 @@ class NotificationService: UNNotificationServiceExtension { } } - NSLog("Sound name: \(String(describing: soundName))") + MXLog.debug("Sound name: \(String(describing: soundName))") return soundName } @@ -590,7 +597,7 @@ class NotificationService: UNNotificationServiceExtension { if #available(iOS 13.0, *) { if event.isEncrypted { guard let clearEvent = event.clear else { - NSLog("[NotificationService] sendVoipPush: Do not send a VoIP push for undecrypted event, it'll cause a crash.") + MXLog.debug("[NotificationService] sendVoipPush: Do not send a VoIP push for undecrypted event, it'll cause a crash.") return } @@ -617,14 +624,14 @@ class NotificationService: UNNotificationServiceExtension { sender: event.sender, timeout: NSE.Constants.voipPushRequestTimeout, success: { [weak self] (rejected) in - NSLog("[NotificationService] sendVoipPush succeeded, rejected tokens: \(rejected)") + MXLog.debug("[NotificationService] sendVoipPush succeeded, rejected tokens: \(rejected)") guard let self = self else { return } self.ongoingVoIPPushRequests.removeValue(forKey: event.eventId) self.fallbackToBestAttemptContent(forEventId: event.eventId) }) { [weak self] (error) in - NSLog("[NotificationService] sendVoipPush failed with error: \(error)") + MXLog.debug("[NotificationService] sendVoipPush failed with error: \(error)") guard let self = self else { return } self.ongoingVoIPPushRequests.removeValue(forKey: event.eventId) diff --git a/RiotShareExtension/Managers/ShareExtensionManager.m b/RiotShareExtension/Managers/ShareExtensionManager.m index a8922b904..47dfb03c4 100644 --- a/RiotShareExtension/Managers/ShareExtensionManager.m +++ b/RiotShareExtension/Managers/ShareExtensionManager.m @@ -77,13 +77,20 @@ typedef NS_ENUM(NSInteger, ImageCompressionMode) // Set static application settings sharedInstance->_configuration = [CommonConfiguration new]; [sharedInstance.configuration setupSettings]; - + // NSLog -> console.log file when not debugging the app - if (!isatty(STDERR_FILENO)) - { - [MXLogger setSubLogName:@"share"]; - [MXLogger redirectNSLogToFiles:YES]; + MXLogConfiguration *configuration = [[MXLogConfiguration alloc] init]; + configuration.logLevel = MXLogLevelVerbose; + configuration.logFilesSizeLimit = 0; + configuration.maxLogFilesCount = 10; + configuration.subLogName = @"share"; + + // Redirect NSLogs to files only if we are not debugging + if (!isatty(STDERR_FILENO)) { + configuration.redirectLogsToFiles = YES; } + + [MXLog configure:configuration]; }); return sharedInstance; } @@ -312,7 +319,7 @@ typedef NS_ENUM(NSInteger, ImageCompressionMode) } else { - NSLog(@"[ShareExtensionManager] sendContentToRoom: failed to loadItemForTypeIdentifier. Error: %@", error); + MXLogDebug(@"[ShareExtensionManager] sendContentToRoom: failed to loadItemForTypeIdentifier. Error: %@", error); dispatch_group_leave(requestsGroup); } @@ -636,7 +643,7 @@ typedef NS_ENUM(NSInteger, ImageCompressionMode) self.imageCompressionMode = ImageCompressionModeNone; } - NSLog(@"[ShareExtensionManager] Send %lu image(s) without compression prompt using compression mode: %ld", (unsigned long)self.pendingImages.count, (long)self.imageCompressionMode); + MXLogDebug(@"[ShareExtensionManager] Send %lu image(s) without compression prompt using compression mode: %ld", (unsigned long)self.pendingImages.count, (long)self.imageCompressionMode); if (shareBlock) { @@ -830,8 +837,8 @@ typedef NS_ENUM(NSInteger, ImageCompressionMode) NSUInteger imageWidth = compressionSize.imageSize.width; NSUInteger imageHeight = compressionSize.imageSize.height; - NSLog(@"[ShareExtensionManager] User choose image compression with output size %lu x %lu (output file size: %@)", (unsigned long)imageWidth, (unsigned long)imageHeight, fileSize); - NSLog(@"[ShareExtensionManager] Number of images to send: %lu", (unsigned long)self.pendingImages.count); + MXLogDebug(@"[ShareExtensionManager] User choose image compression with output size %lu x %lu (output file size: %@)", (unsigned long)imageWidth, (unsigned long)imageHeight, fileSize); + MXLogDebug(@"[ShareExtensionManager] Number of images to send: %lu", (unsigned long)self.pendingImages.count); } // Log memory usage. @@ -850,11 +857,11 @@ typedef NS_ENUM(NSInteger, ImageCompressionMode) if (kerr == KERN_SUCCESS) { - NSLog(@"[ShareExtensionManager] Memory in use (in MB): %f", memoryUsedInMegabytes); + MXLogDebug(@"[ShareExtensionManager] Memory in use (in MB): %f", memoryUsedInMegabytes); } else { - NSLog(@"[ShareExtensionManager] Error with task_info(): %s", mach_error_string(kerr)); + MXLogDebug(@"[ShareExtensionManager] Error with task_info(): %s", mach_error_string(kerr)); } } @@ -890,7 +897,7 @@ typedef NS_ENUM(NSInteger, ImageCompressionMode) - (void)didReceiveMemoryWarning:(NSNotification*)notification { - NSLog(@"[ShareExtensionManager] Did receive memory warning"); + MXLogDebug(@"[ShareExtensionManager] Did receive memory warning"); [self logMemoryUsage]; } @@ -901,7 +908,7 @@ typedef NS_ENUM(NSInteger, ImageCompressionMode) [self didStartSendingToRoom:room]; if (!text) { - NSLog(@"[ShareExtensionManager] loadItemForTypeIdentifier: failed."); + MXLogDebug(@"[ShareExtensionManager] loadItemForTypeIdentifier: failed."); if (failureBlock) { failureBlock(nil); @@ -915,7 +922,7 @@ typedef NS_ENUM(NSInteger, ImageCompressionMode) successBlock(); } } failure:^(NSError *error) { - NSLog(@"[ShareExtensionManager] sendTextMessage failed."); + MXLogDebug(@"[ShareExtensionManager] sendTextMessage failed."); if (failureBlock) { failureBlock(error); @@ -928,7 +935,7 @@ typedef NS_ENUM(NSInteger, ImageCompressionMode) [self didStartSendingToRoom:room]; if (!fileUrl) { - NSLog(@"[ShareExtensionManager] loadItemForTypeIdentifier: failed."); + MXLogDebug(@"[ShareExtensionManager] loadItemForTypeIdentifier: failed."); if (failureBlock) { failureBlock(nil); @@ -947,7 +954,7 @@ typedef NS_ENUM(NSInteger, ImageCompressionMode) successBlock(); } } failure:^(NSError *error) { - NSLog(@"[ShareExtensionManager] sendFile failed."); + MXLogDebug(@"[ShareExtensionManager] sendFile failed."); if (failureBlock) { failureBlock(error); @@ -985,7 +992,7 @@ typedef NS_ENUM(NSInteger, ImageCompressionMode) // Sanity check if (!mimeType) { - NSLog(@"[ShareExtensionManager] sendImage failed. Cannot determine MIME type of %@", itemProvider); + MXLogDebug(@"[ShareExtensionManager] sendImage failed. Cannot determine MIME type of %@", itemProvider); if (failureBlock) { failureBlock(nil); @@ -1072,7 +1079,7 @@ typedef NS_ENUM(NSInteger, ImageCompressionMode) } } failure:^(NSError *error) { - NSLog(@"[ShareExtensionManager] sendImage failed."); + MXLogDebug(@"[ShareExtensionManager] sendImage failed."); if (failureBlock) { failureBlock(error); @@ -1085,7 +1092,7 @@ typedef NS_ENUM(NSInteger, ImageCompressionMode) { if (imageDatas.count == 0 || imageDatas.count != itemProviders.count) { - NSLog(@"[ShareExtensionManager] sendImages: no images to send."); + MXLogDebug(@"[ShareExtensionManager] sendImages: no images to send."); if (failureBlock) { @@ -1149,7 +1156,7 @@ typedef NS_ENUM(NSInteger, ImageCompressionMode) [self didStartSendingToRoom:room]; if (!videoLocalUrl) { - NSLog(@"[ShareExtensionManager] loadItemForTypeIdentifier: failed."); + MXLogDebug(@"[ShareExtensionManager] loadItemForTypeIdentifier: failed."); if (failureBlock) { failureBlock(nil); @@ -1173,7 +1180,7 @@ typedef NS_ENUM(NSInteger, ImageCompressionMode) successBlock(); } } failure:^(NSError *error) { - NSLog(@"[ShareExtensionManager] sendVideo failed."); + MXLogDebug(@"[ShareExtensionManager] sendVideo failed."); if (failureBlock) { failureBlock(error); diff --git a/RiotShareExtension/Modules/Share/DataSources/ShareDataSource.m b/RiotShareExtension/Modules/Share/DataSources/ShareDataSource.m index c454c5e74..8952fdafe 100644 --- a/RiotShareExtension/Modules/Share/DataSources/ShareDataSource.m +++ b/RiotShareExtension/Modules/Share/DataSources/ShareDataSource.m @@ -98,7 +98,7 @@ } failure:^(NSError * _Nonnull error) { - NSLog(@"[ShareDataSource failed to get room summaries]"); + MXLogDebug(@"[ShareDataSource failed to get room summaries]"); }]; } diff --git a/RiotShareExtension/Modules/Share/Listing/RoomsListViewController.m b/RiotShareExtension/Modules/Share/Listing/RoomsListViewController.m index 726efa228..52ccd3af3 100644 --- a/RiotShareExtension/Modules/Share/Listing/RoomsListViewController.m +++ b/RiotShareExtension/Modules/Share/Listing/RoomsListViewController.m @@ -174,7 +174,7 @@ } failure:^(NSError *error) { - NSLog(@"[RoomsListViewController] failed to prepare matrix session]"); + MXLogDebug(@"[RoomsListViewController] failed to prepare matrix session]"); }]; }]; diff --git a/SiriIntents/IntentHandler.m b/SiriIntents/IntentHandler.m index f7f48cbe6..908ed40ed 100644 --- a/SiriIntents/IntentHandler.m +++ b/SiriIntents/IntentHandler.m @@ -43,11 +43,18 @@ [_configuration setupSettings]; // NSLog -> console.log file when not debugging the app - if (!isatty(STDERR_FILENO)) - { - [MXLogger setSubLogName:@"siri"]; - [MXLogger redirectNSLogToFiles:YES]; + MXLogConfiguration *configuration = [[MXLogConfiguration alloc] init]; + configuration.logLevel = MXLogLevelVerbose; + configuration.logFilesSizeLimit = 0; + configuration.maxLogFilesCount = 10; + configuration.subLogName = @"siri"; + + // Redirect NSLogs to files only if we are not debugging + if (!isatty(STDERR_FILENO)) { + configuration.redirectLogsToFiles = YES; } + + [MXLog configure:configuration]; } return self; }