Skip to content

Commit

Permalink
log cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
heckj committed May 1, 2024
1 parent e9cf6a8 commit 359e102
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions MeetingNotes/Logger+extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ extension Logger: @unchecked Sendable {

/// Logs the Document interactions, such as saving and loading.
static let document = Logger(subsystem: subsystem, category: "Document")

/// Logs messages that might pertain to initiating, or receiving, sync updates
static let syncflow = Logger(subsystem: subsystem, category: "SyncFlow")
}
5 changes: 4 additions & 1 deletion MeetingNotes/MeetingNotesDocument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ final class MeetingNotesDocument: ReferenceFileDocument {
}

syncedDocumentTrigger = doc.objectWillChange.sink {
Logger.syncflow.trace("\(self.id) ** objectWillChange **")
self.objectWillChange.send()
}
}
Expand Down Expand Up @@ -151,6 +152,7 @@ final class MeetingNotesDocument: ReferenceFileDocument {
.throttle(for: 1.0, scheduler: DispatchQueue.main, latest: true)
.receive(on: RunLoop.main)
.sink {
Logger.syncflow.trace("\(self.id) ** objectWillChange (1 sec delay) **")
do {
try self.getModelUpdates()
} catch {
Expand Down Expand Up @@ -195,13 +197,14 @@ final class MeetingNotesDocument: ReferenceFileDocument {

/// Updates the Automerge document with the current value from the model.
func storeModelUpdates() throws {
Logger.syncflow.debug("Storing model updates")
try modelEncoder.encode(model)
self.objectWillChange.send()
}

/// Updates the model document with any changed values in the Automerge document.
func getModelUpdates() throws {
// Logger.document.debug("Updating model from Automerge document.")
Logger.syncflow.debug("Loading model updates")
model = try modelDecoder.decode(MeetingNotesModel.self)
}

Expand Down

0 comments on commit 359e102

Please sign in to comment.