From 31c9d942ff05a5cd00c229222fd08b95f0e26b86 Mon Sep 17 00:00:00 2001 From: eduardopietre Date: Sun, 8 May 2022 19:31:51 -0300 Subject: [PATCH] Added traces to DataExporter. --- xdrip/Constants/ConstantsLog.swift | 3 +++ xdrip/Utilities/HouseKeeping/DataExporter.swift | 14 ++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/xdrip/Constants/ConstantsLog.swift b/xdrip/Constants/ConstantsLog.swift index 6a0eda94..43e9ef43 100644 --- a/xdrip/Constants/ConstantsLog.swift +++ b/xdrip/Constants/ConstantsLog.swift @@ -159,6 +159,9 @@ enum ConstantsLog { /// for use in Libre2BLEUtilities static let categoryAppDelegate = "AppDelegate " + + /// for use in DataExporter + static let dataExporter = "DataExporter " } diff --git a/xdrip/Utilities/HouseKeeping/DataExporter.swift b/xdrip/Utilities/HouseKeeping/DataExporter.swift index 515a3c28..accf9f32 100644 --- a/xdrip/Utilities/HouseKeeping/DataExporter.swift +++ b/xdrip/Utilities/HouseKeeping/DataExporter.swift @@ -7,6 +7,7 @@ // import Foundation +import OSLog /// DataExporter is tha class responsible for @@ -32,6 +33,10 @@ public class DataExporter { /// Calibrations instance private let calibrationsAccessor: CalibrationsAccessor + /// Log instance + private var log = OSLog(subsystem: ConstantsLog.subSystem, category: ConstantsLog.dataExporter) + + // MARK: - initializer init(coreDataManager: CoreDataManager) { @@ -57,8 +62,7 @@ public class DataExporter { let asString = String(data: jsonData, encoding: .utf8) return asString } catch let error { - // TODO: add trace - // trace("in convertToJSON, error = %{public}@", log: self.log, category: ConstantsLog., type: .error, error.localizedDescription) + trace("in convertToJSON, error = %{public}@", log: self.log, category: ConstantsLog.dataExporter, type: .error, error.localizedDescription) } return nil @@ -149,8 +153,7 @@ public class DataExporter { self.generateJSON { json in /// Json must not be nil. guard let json = json else { - // TODO: add trace - // trace("in convertToJSON, error = %{public}@", log: self.log, category: ConstantsLog., type: .error, error.localizedDescription) + trace("in exportAllData, json is nil", log: self.log, category: ConstantsLog.dataExporter, type: .error) callback(nil) return } @@ -171,8 +174,7 @@ public class DataExporter { try json.write(to: filePath, atomically: false, encoding: .utf8) callback(filePath) } catch let error { - // TODO: add trace - // trace("in convertToJSON, error = %{public}@", log: self.log, category: ConstantsLog., type: .error, error.localizedDescription) + trace("in exportAllData, error = %{public}@", log: self.log, category: ConstantsLog.dataExporter, type: .error, error.localizedDescription) callback(nil) } }