Calls SDKs iOS v1
Calls SDKs iOS
Calls SDKs
iOS
Version 1

Logger

Copy link

Calls SDK for iOS offers a logging system that allows you to keep track of a number of events and activities while running your app. You can closely monitor the operation of the Calls SDK and improve debug efficiency using our log system.


SBCLogger class

Copy link

To display log output to the console, implement SBCLogger.setLoggerLevel() as shown below:

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

Log levels

Copy link

Log levels can be used to control log outputs. If logging is enabled at the specified log level, it also enables logging at all higher levels. The priority level of logs are in the following order: info (0) < warning (1) < error (2) < none (3).

LevelDescription

info

Logs that track the general events of the Calls SDK.

warning

Logs that indicate potentially problematic situations.

error

Logs that represent the failure of the Calls SDK execution.

none (default)

Not used for writing log outputs.

Note: Calls SDKs for iOS and JavaScript share the same order for the priority level of logs.

Log format

Copy link

The log output is written in the following format: {date time} {prefix} {type} {thread} {classFuncName} | {message}.

Methods

Copy link

This class provides the following methods:

NameDescription

setLoggerLevel(_:)

Determines the log level which type of logs are displayed to the console and delivered to custom log receivers.

add(receiver:)

Adds a custom log receiver to the SBCLogger.

remove(receiver:)

Removes a custom log receiver from the SBCLogger.


SBCLogReceiver protocol

Copy link

If you want to display log outputs in other tools such as device logs, console.app, or on your server, implement the SBCLogReceiver protocol to your custom log class as shown below.

class CustomLogReceiver: SBCLogReceiver {
    func log(message: String) {
        #if DEBUG
            NSLog(message)
        #endif
    }
    ...
}

class AppDelegate: UIResponder, UIApplicationDelegate {
    let myLogReceiver = CustomLogReceiver()

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        SBCLogger.add(receiver: self.myLogReceiver)
        ...
    }
}