iOS
Calls Logger

Logger

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


SBCLogger class

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

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

    SBCLogger.setLoggerLevel(.info)

    ...
}

Log levels

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

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

Methods

This class provides the following methods:

MethodDescription

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

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.

Light Color Skin
Copy
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)

        ...
    }
}