Skip to content

Logging

Marco Brescianini edited this page Nov 7, 2024 · 1 revision

Logging can be enabled at any time using the static properties on the KaleyraVideo singleton instance. By default the SDK will not log anything. You must tell the SDK where you want it to log events and at which level.

The SDK provides two loggers:

  • console, when enabled it will log events into the device console
  • file, when enabled it will log events into a rolling file on the device

Here's an example where we enable logging any events into the console and the file loggers:

import KaleyraVideoSDK

class AppDelegate: NSObject, UIApplicationDelegate {

    func application(_ app: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
        KaleyraVideo.logLevel = .all
        KaleyraVideo.loggers = [.console, .file]
        return true
    }
}

If you want to disable logging, then you just need to tell the SDK to disable it:

import KaleyraVideoSDK

class AppDelegate: NSObject, UIApplicationDelegate {

    func application(_ app: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
        KaleyraVideo.logLevel = .off
        return true
    }
}

Caution

The logs are there for diagnostic purpose only, you should not enable logging in production as it will slow down your app and worse it may leak sensitive user information.

Clone this wiki locally