Added traces to DataExporter.

This commit is contained in:
eduardopietre 2022-05-08 19:31:51 -03:00
parent f3ce6d7c57
commit 31c9d942ff
2 changed files with 11 additions and 6 deletions

View File

@ -159,6 +159,9 @@ enum ConstantsLog {
/// for use in Libre2BLEUtilities
static let categoryAppDelegate = "AppDelegate "
/// for use in DataExporter
static let dataExporter = "DataExporter "
}

View File

@ -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)
}
}