mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Logging changes
- Adds `Logging` protocol - Moves to Swift-style `OSLog` usage os_log to Logger os_log audit Replacment of os.log with Logging
This commit is contained in:
@@ -11,7 +11,6 @@ import RSCore
|
||||
import RSParser
|
||||
import RSWeb
|
||||
import SyncDatabase
|
||||
import os.log
|
||||
import Secrets
|
||||
|
||||
public enum ReaderAPIAccountDelegateError: LocalizedError {
|
||||
@@ -34,14 +33,13 @@ public enum ReaderAPIAccountDelegateError: LocalizedError {
|
||||
}
|
||||
}
|
||||
|
||||
final class ReaderAPIAccountDelegate: AccountDelegate {
|
||||
final class ReaderAPIAccountDelegate: AccountDelegate, Logging {
|
||||
|
||||
private let variant: ReaderAPIVariant
|
||||
|
||||
private let database: SyncDatabase
|
||||
|
||||
private let caller: ReaderAPICaller
|
||||
private var log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "ReaderAPI")
|
||||
|
||||
var behaviors: AccountBehaviors {
|
||||
var behaviors: AccountBehaviors = [.disallowOPMLImports, .disallowFeedInMultipleFolders]
|
||||
@@ -196,7 +194,7 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
|
||||
}
|
||||
|
||||
func sendArticleStatus(for account: Account, completion: @escaping ((Result<Void, Error>) -> Void)) {
|
||||
os_log(.debug, log: log, "Sending article statuses...")
|
||||
logger.debug("Sending article statuses...")
|
||||
|
||||
database.selectForProcessing { result in
|
||||
|
||||
@@ -229,7 +227,7 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
|
||||
}
|
||||
|
||||
group.notify(queue: DispatchQueue.main) {
|
||||
os_log(.debug, log: self.log, "Done sending article statuses.")
|
||||
self.logger.debug("Done sending article statuses.")
|
||||
completion(.success(()))
|
||||
}
|
||||
}
|
||||
@@ -244,7 +242,7 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
|
||||
}
|
||||
|
||||
func refreshArticleStatus(for account: Account, completion: @escaping ((Result<Void, Error>) -> Void)) {
|
||||
os_log(.debug, log: log, "Refreshing article statuses...")
|
||||
logger.debug("Refreshing article statuses...")
|
||||
|
||||
let group = DispatchGroup()
|
||||
var errorOccurred = false
|
||||
@@ -258,7 +256,7 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
|
||||
}
|
||||
case .failure(let error):
|
||||
errorOccurred = true
|
||||
os_log(.info, log: self.log, "Retrieving unread entries failed: %@.", error.localizedDescription)
|
||||
self.logger.info("Retrieving unread entries failed: \(error.localizedDescription)")
|
||||
group.leave()
|
||||
}
|
||||
|
||||
@@ -273,14 +271,14 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
|
||||
}
|
||||
case .failure(let error):
|
||||
errorOccurred = true
|
||||
os_log(.info, log: self.log, "Retrieving starred entries failed: %@.", error.localizedDescription)
|
||||
self.logger.info("Retrieving starred entries failed: \(error.localizedDescription)")
|
||||
group.leave()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
group.notify(queue: DispatchQueue.main) {
|
||||
os_log(.debug, log: self.log, "Done refreshing article statuses.")
|
||||
self.logger.debug("Done refreshing article statuses.")
|
||||
if errorOccurred {
|
||||
completion(.failure(ReaderAPIAccountDelegateError.unknown))
|
||||
} else {
|
||||
@@ -342,7 +340,7 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
|
||||
self.clearFolderRelationship(for: feed, folderExternalID: folder.externalID)
|
||||
}
|
||||
case .failure(let error):
|
||||
os_log(.error, log: self.log, "Remove feed error: %@.", error.localizedDescription)
|
||||
self.logger.error("Remove feed error: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -361,7 +359,7 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
|
||||
account.clearWebFeedMetadata(feed)
|
||||
}
|
||||
case .failure(let error):
|
||||
os_log(.error, log: self.log, "Remove feed error: %@.", error.localizedDescription)
|
||||
self.logger.error("Remove feed error: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -593,7 +591,7 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
|
||||
case .success:
|
||||
break
|
||||
case .failure(let error):
|
||||
os_log(.error, log: self.log, "Restore folder feed error: %@.", error.localizedDescription)
|
||||
self.logger.error("Restore folder feed error: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -711,7 +709,7 @@ private extension ReaderAPIAccountDelegate {
|
||||
|
||||
guard !folderTags.isEmpty else { return }
|
||||
|
||||
os_log(.debug, log: log, "Syncing folders with %ld tags.", folderTags.count)
|
||||
logger.debug("Syncing folders with \(folderTags.count) tags.")
|
||||
|
||||
let readerFolderExternalIDs = folderTags.compactMap { $0.tagID }
|
||||
|
||||
@@ -751,7 +749,7 @@ private extension ReaderAPIAccountDelegate {
|
||||
guard let subscriptions = subscriptions else { return }
|
||||
assert(Thread.isMainThread)
|
||||
|
||||
os_log(.debug, log: log, "Syncing feeds with %ld subscriptions.", subscriptions.count)
|
||||
logger.debug("Syncing feeds with \(subscriptions.count) subscriptions")
|
||||
|
||||
let subFeedIds = subscriptions.map { $0.feedID }
|
||||
|
||||
@@ -793,7 +791,7 @@ private extension ReaderAPIAccountDelegate {
|
||||
func syncFeedFolderRelationship(_ account: Account, _ subscriptions: [ReaderAPISubscription]?) {
|
||||
guard let subscriptions = subscriptions else { return }
|
||||
assert(Thread.isMainThread)
|
||||
os_log(.debug, log: log, "Syncing taggings with %ld subscriptions.", subscriptions.count)
|
||||
logger.debug("Syncing taggins with \(subscriptions.count) subscriptions.")
|
||||
|
||||
// Set up some structures to make syncing easier
|
||||
let folderDict = externalIDToFolderDictionary(with: account.folders)
|
||||
@@ -887,7 +885,7 @@ private extension ReaderAPIAccountDelegate {
|
||||
self.database.deleteSelectedForProcessing(articleIDGroup.map { $0 } )
|
||||
group.leave()
|
||||
case .failure(let error):
|
||||
os_log(.error, log: self.log, "Article status sync call failed: %@.", error.localizedDescription)
|
||||
self.logger.error("Article status sync call failed: \(error.localizedDescription)")
|
||||
self.database.resetSelectedForProcessing(articleIDGroup.map { $0 } )
|
||||
group.leave()
|
||||
}
|
||||
@@ -987,7 +985,7 @@ private extension ReaderAPIAccountDelegate {
|
||||
return
|
||||
}
|
||||
|
||||
os_log(.debug, log: self.log, "Refreshing missing articles...")
|
||||
self.logger.debug("Refreshing missing articles...")
|
||||
let group = DispatchGroup()
|
||||
|
||||
let articleIDs = Array(fetchedArticleIDs)
|
||||
@@ -1007,7 +1005,7 @@ private extension ReaderAPIAccountDelegate {
|
||||
}
|
||||
|
||||
case .failure(let error):
|
||||
os_log(.error, log: self.log, "Refresh missing articles failed: %@.", error.localizedDescription)
|
||||
self.logger.error("Refresh missing articles failed: \(error.localizedDescription)")
|
||||
group.leave()
|
||||
}
|
||||
}
|
||||
@@ -1015,7 +1013,7 @@ private extension ReaderAPIAccountDelegate {
|
||||
|
||||
group.notify(queue: DispatchQueue.main) {
|
||||
self.refreshProgress.completeTask()
|
||||
os_log(.debug, log: self.log, "Done refreshing missing articles.")
|
||||
self.logger.debug("Done refreshing missing articles.")
|
||||
completion()
|
||||
}
|
||||
}
|
||||
@@ -1121,7 +1119,7 @@ private extension ReaderAPIAccountDelegate {
|
||||
case .success(let pendingArticleIDs):
|
||||
process(pendingArticleIDs)
|
||||
case .failure(let error):
|
||||
os_log(.error, log: self.log, "Sync Article Read Status failed: %@.", error.localizedDescription)
|
||||
self.logger.error("Sync Article Read Status failed: \(error.localizedDescription)")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1170,7 +1168,7 @@ private extension ReaderAPIAccountDelegate {
|
||||
case .success(let pendingArticleIDs):
|
||||
process(pendingArticleIDs)
|
||||
case .failure(let error):
|
||||
os_log(.error, log: self.log, "Sync Article Starred Status failed: %@.", error.localizedDescription)
|
||||
self.logger.error("Sync Article Starred Status failed: \(error.localizedDescription)")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user