Logging

Logging is enabled by default in the HealthRhythms SDK.

Disable Logging

To disable logging, you can pass false to Sensing.logging(enable:) early in your application lifecycle like so:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

    // Disable logging.
    Sensing.logging(enable: false)

    // any setup code relevant to your app
}

Subscribe to all the HealthRhythms Logs

The HealthRhythms SDK allows you to subscribe to all the SDK logs, which is helpful if you wish to use our logs in your own logging platform.

To accomplish this, import the HRUtils module, and implement the LoggerDelegate‘s didLog(_ message:, _ parameters:, file: , function:, line:) method. The code snippet below implements LoggerDelegate in the project’s AppDelegate.swift:

import HRUtils

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, LoggerDelegate {

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

        // Set the logger delegate.
        Sensing.loggerDelegate = self

        // any setup code relevant to your app
    }

    // MARK: - Logger Delegate

    func didLog(_ message: String, _ parameters: [String: Any]?, file: StaticString, function: StaticString, line: UInt) {
        YourCustomLogger.log("[LoggerDelegate] message: \(message) parameters: \(String(describing: parameters)) file: \(file) function: \(function) line: \(line)")
    }
}