Skip to content

Commit

Permalink
Merge pull request #372 from loopandlearn/remove-excessive-logging
Browse files Browse the repository at this point in the history
Decrease HealthKitManager debug logging
  • Loading branch information
MikePlante1 authored Aug 4, 2024
2 parents 08eba43 + d8ac49a commit 0efde61
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 33 deletions.
1 change: 0 additions & 1 deletion FreeAPS/Sources/APS/DeviceDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,6 @@ extension BaseDeviceDataManager: PumpManagerDelegate {
completion: @escaping (_ error: Error?) -> Void
) {
dispatchPrecondition(condition: .onQueue(processQueue))
debug(.deviceManager, "New pump events:\n\(events.map(\.title).joined(separator: "\n"))")

// filter buggy TBRs > maxBasal from MDT
let events = events.filter {
Expand Down
35 changes: 3 additions & 32 deletions FreeAPS/Sources/Services/HealthKit/HealthKitManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,7 @@ final class BaseHealthKitManager: HealthKitManager, Injectable, CarbsObserver, P
}

healthKitStore.save(samplesToSave) { (success: Bool, error: Error?) -> Void in
if success {
for sample in samplesToSave {
debug(
.service,
"Stored blood glucose \(sample.quantity) in HealthKit Store! Metadata: \(String(describing: sample.metadata?.values))"
)
}
} else {
if !success {
debug(.service, "Failed to store blood glucose in HealthKit Store!")
debug(.service, error?.localizedDescription ?? "Unknown error")
}
Expand Down Expand Up @@ -220,14 +213,7 @@ final class BaseHealthKitManager: HealthKitManager, Injectable, CarbsObserver, P
}

healthKitStore.save(samplesToSave) { (success: Bool, error: Error?) -> Void in
if success {
for sample in samplesToSave {
debug(
.service,
"Stored carb entry \(sample.quantity) in HealthKit Store! Metadata: \(String(describing: sample.metadata?.values))"
)
}
} else {
if !success {
debug(.service, "Failed to store carb entry in HealthKit Store!")
debug(.service, error?.localizedDescription ?? "Unknown error")
}
Expand Down Expand Up @@ -296,14 +282,7 @@ final class BaseHealthKitManager: HealthKitManager, Injectable, CarbsObserver, P
}

healthKitStore.save(bolusSamples + basalSamples) { (success: Bool, error: Error?) -> Void in
if success {
for sample in bolusSamples + basalSamples {
debug(
.service,
"Stored insulin entry in HealthKit Store! Metadata: \(String(describing: sample.metadata?.values))"
)
}
} else {
if !success {
debug(.service, "Failed to store insulin entry in HealthKit Store!")
debug(.service, error?.localizedDescription ?? "Unknown error")
}
Expand Down Expand Up @@ -491,7 +470,6 @@ final class BaseHealthKitManager: HealthKitManager, Injectable, CarbsObserver, P

private func prepareBGSamplesToPublisherFetch(_ samples: [HKQuantitySample]) {
dispatchPrecondition(condition: .onQueue(processQueue))
debug(.service, "Start preparing samples: \(String(describing: samples))")

newGlucose += samples
.compactMap { sample -> HealthKitSample? in
Expand Down Expand Up @@ -520,11 +498,6 @@ final class BaseHealthKitManager: HealthKitManager, Injectable, CarbsObserver, P
.filter { $0.dateString >= Date().addingTimeInterval(-1.days.timeInterval) }

newGlucose = newGlucose.removeDublicates()

debug(
.service,
"Current BloodGlucose.Type objects will be send from Publisher during fetch: \(String(describing: newGlucose))"
)
}

// MARK: - GlucoseSource
Expand All @@ -540,9 +513,7 @@ final class BaseHealthKitManager: HealthKitManager, Injectable, CarbsObserver, P
}

self.processQueue.async {
// debug(.service, "Start fetching HealthKitManager")
guard self.settingsManager.settings.useAppleHealth else {
debug(.service, "HealthKitManager cant return any data, because useAppleHealth option is disable")
promise(.success([]))
return
}
Expand Down

0 comments on commit 0efde61

Please sign in to comment.