mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-22 23:58:36 +01:00
Add logging to DataFile.
This commit is contained in:
parent
5a02ba417f
commit
9227924f4e
@ -31,7 +31,6 @@ import Core
|
||||
|
||||
func markAsDirty() {
|
||||
|
||||
logger.info("OPMLFile marked dirty: \(self.fileURL)")
|
||||
dataFile.markAsDirty()
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,11 @@ public protocol DataFileDelegate: AnyObject {
|
||||
private let fileURL: URL
|
||||
private let saveQueue: CoalescingQueue
|
||||
|
||||
private static let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "DataFile")
|
||||
private var logger: Logger {
|
||||
Self.logger
|
||||
}
|
||||
|
||||
public init(fileURL: URL) {
|
||||
|
||||
self.fileURL = fileURL
|
||||
@ -38,14 +43,17 @@ public protocol DataFileDelegate: AnyObject {
|
||||
public func markAsDirty() {
|
||||
|
||||
isDirty = true
|
||||
logger.info("Data file marked dirty: \(self.fileURL)")
|
||||
}
|
||||
|
||||
public func save() {
|
||||
|
||||
assert(Thread.isMainThread)
|
||||
isDirty = false
|
||||
logger.info("Saving data file: \(self.fileURL)")
|
||||
|
||||
guard let data = delegate?.data(for: self) else {
|
||||
logger.error("Delegate did not return data for data file: \(self.fileURL)")
|
||||
return
|
||||
}
|
||||
|
||||
@ -53,6 +61,7 @@ public protocol DataFileDelegate: AnyObject {
|
||||
try data.write(to: fileURL)
|
||||
} catch {
|
||||
delegate?.dataFileWriteToDiskDidFail(for: self, error: error)
|
||||
logger.error("Data file did fail to write to disk: \(self.fileURL)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user