Skip to main content
Skip table of contents

Logging in production builds

The application can enable logging, which is not enabled by default, in production builds by implementing a class conforming with a protocol IOTVLogProvider exposed by SDK. The application implements the logProvider() API in this class, which is called with log information by SDK framework for the application to process that log. The application needs to pass the instance of this class using API setLogProvider() in SDK framework.

Exposed protocol and API in the SDK

CODE
// The protocol defines a method that application need to implement to receive the log from SDK in production build.
@objc public protocol IOTVLogProvider: NSObjectProtocol {
    
    func logProvider(xLog: String)

}

// Set the instance of a class conforming to IOTVLogProvider protocol.
func setLogProvider(xLogProvider: IOTVLogProvider);

Steps to enable log production

Implementing a class conforming to protocol IOTVLogProvider

Below is the sample class implementation conforming to the protocol IOTVLogProvider .

CODE
public class AppLogProvider: NSObject , IOTVLogProvider {

    public func logProvider(xLog: String) {
        // Application to process this log.
        print("[APP]: \(xLog)")
    }
}

Creating an instance of the class and setting it to the SDK framework

The application can create the instance of the log provider class and set it to the SDK.

CODE
//Create the instance of log provider class.
let logProvider = AppLogProvider()

// Set the appropriate log level in SDK
OTVSDK.setLogging(level: .debug)  //possible log level: .debug, .info, .warning, .error

//Set the instance of log provider.
OTVSDK.setLogProvider(xLogProvider: logProvider)
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.