DexcareSDKLogger

public protocol DexcareSDKLogger

An example of a Logger that will log to the console. The DexCareSDK will use this logger calling the log(message, level, sender) function in this class with information.

class ConsoleLogger: DexcareSDKLogger {

   static var shared: ConsoleLogger = ConsoleLogger()

   func log(_ message: String, level: DexcareSDKLogLevel, sender: String) {
       let emoji: String
       switch level {
           case .verbose: emoji = "➡️"
           case .debug: emoji = "✳️"
           case .info: emoji = "✏️"
           case .warning: emoji = "⚠️"
           case .error: emoji = "❌"
       }
       NSLog("\(emoji) \(sender): \(message)")
   }
}

This would show in the console as:

✳️ DexcareSDK: Response debug in 0.58s for: https://baseurl/v1/departments/epic.acme.one3511101000?byId=true&product=healthconnect-iOS - Status: 200 - Correlation: 16465A2F-69CE-4AF5-9FFA-827673AEF8F1

The Correlation ID can help DexCare debug results.

  • The logging function

    Declaration

    Swift

    func log(
        // sourcery: SaveParameters
        _ message: String,
        // sourcery: SaveParameters
        level: DexcareSDKLogLevel,
        sender: String
    )