|
|
@@ -69,7 +69,7 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable {
|
|
|
|
|
|
guard existingEvents.isEmpty else {
|
|
|
// Duplicate found, do not store the event
|
|
|
- print("Duplicate event found with timestamp: \(event.date)")
|
|
|
+ debug(.coreData, "Duplicate event found with timestamp: \(event.date)")
|
|
|
|
|
|
if let existingEvent = existingEvents.first(where: { $0.type == EventType.bolus.rawValue }) {
|
|
|
if existingEvent.timestamp == event.date {
|
|
|
@@ -81,7 +81,7 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable {
|
|
|
existingEvent.isUploadedToHealth = false
|
|
|
existingEvent.isUploadedToTidepool = false
|
|
|
|
|
|
- print("Updated existing event with smaller value: \(amount)")
|
|
|
+ debug(.coreData, "Updated existing event with smaller value: \(amount)")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -108,7 +108,7 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable {
|
|
|
|
|
|
guard existingEvents.isEmpty else {
|
|
|
// Duplicate found, do not store the event
|
|
|
- print("Duplicate event found with timestamp: \(event.date)")
|
|
|
+ debug(.coreData, "Duplicate event found with timestamp: \(event.date)")
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
@@ -137,7 +137,7 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable {
|
|
|
case .suspend:
|
|
|
guard existingEvents.isEmpty else {
|
|
|
// Duplicate found, do not store the event
|
|
|
- print("Duplicate event found with timestamp: \(event.date)")
|
|
|
+ debug(.coreData, "Duplicate event found with timestamp: \(event.date)")
|
|
|
continue
|
|
|
}
|
|
|
let newPumpEvent = PumpEventStored(context: self.context)
|
|
|
@@ -151,7 +151,7 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable {
|
|
|
case .resume:
|
|
|
guard existingEvents.isEmpty else {
|
|
|
// Duplicate found, do not store the event
|
|
|
- print("Duplicate event found with timestamp: \(event.date)")
|
|
|
+ debug(.coreData, "Duplicate event found with timestamp: \(event.date)")
|
|
|
continue
|
|
|
}
|
|
|
let newPumpEvent = PumpEventStored(context: self.context)
|
|
|
@@ -165,7 +165,7 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable {
|
|
|
case .rewind:
|
|
|
guard existingEvents.isEmpty else {
|
|
|
// Duplicate found, do not store the event
|
|
|
- print("Duplicate event found with timestamp: \(event.date)")
|
|
|
+ debug(.coreData, "Duplicate event found with timestamp: \(event.date)")
|
|
|
continue
|
|
|
}
|
|
|
let newPumpEvent = PumpEventStored(context: self.context)
|
|
|
@@ -179,7 +179,7 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable {
|
|
|
case .prime:
|
|
|
guard existingEvents.isEmpty else {
|
|
|
// Duplicate found, do not store the event
|
|
|
- print("Duplicate event found with timestamp: \(event.date)")
|
|
|
+ debug(.coreData, "Duplicate event found with timestamp: \(event.date)")
|
|
|
continue
|
|
|
}
|
|
|
let newPumpEvent = PumpEventStored(context: self.context)
|
|
|
@@ -193,7 +193,7 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable {
|
|
|
case .alarm:
|
|
|
guard existingEvents.isEmpty else {
|
|
|
// Duplicate found, do not store the event
|
|
|
- print("Duplicate event found with timestamp: \(event.date)")
|
|
|
+ debug(.coreData, "Duplicate event found with timestamp: \(event.date)")
|
|
|
continue
|
|
|
}
|
|
|
let newPumpEvent = PumpEventStored(context: self.context)
|
|
|
@@ -215,16 +215,15 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable {
|
|
|
try self.context.save()
|
|
|
|
|
|
self.updateSubject.send(())
|
|
|
- debugPrint("\(DebuggingIdentifiers.succeeded) stored pump events in Core Data")
|
|
|
+ debug(.coreData, "\(DebuggingIdentifiers.succeeded) stored pump events in Core Data")
|
|
|
} catch let error as NSError {
|
|
|
- debugPrint("\(DebuggingIdentifiers.failed) failed to store pump events with error: \(error.userInfo)")
|
|
|
+ debug(.coreData, "\(DebuggingIdentifiers.failed) failed to store pump events with error: \(error.userInfo)")
|
|
|
throw error
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func storeExternalInsulinEvent(amount: Decimal, timestamp: Date) async {
|
|
|
- debug(.default, "External insulin saved")
|
|
|
await context.perform {
|
|
|
// create pump event
|
|
|
let newPumpEvent = PumpEventStored(context: self.context)
|
|
|
@@ -246,10 +245,10 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable {
|
|
|
do {
|
|
|
guard self.context.hasChanges else { return }
|
|
|
try self.context.save()
|
|
|
-
|
|
|
+ debug(.coreData, "External insulin saved")
|
|
|
self.updateSubject.send(())
|
|
|
} catch {
|
|
|
- print(error.localizedDescription)
|
|
|
+ debug(.coreData, "Failed to store external insulin in context: \(error)")
|
|
|
}
|
|
|
}
|
|
|
}
|