Skip to content

Commit

Permalink
/issues/4351 - Replaced more NSLog usages, added custom swiftlint err…
Browse files Browse the repository at this point in the history
…or rule for NSLog.
  • Loading branch information
stefanceriu committed Jun 2, 2021
1 parent 01fd7dd commit c916864
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 8 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,11 @@ type_name:
max_length: # warning and error
warning: 150
error: 1000

custom_rules:
ns_log_deprecation:
regex: "NSLog"
match_kinds: identifier
message: "MXLog should be used instead of NSLog"
severity: error

6 changes: 3 additions & 3 deletions Riot/Managers/UserSessions/UserSessionsService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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])
Expand All @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions Riot/Modules/TabBar/TabBarCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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)
}
}
Expand Down

0 comments on commit c916864

Please sign in to comment.