Debugging

Enable SDK debugging or provide your custom logger.

Enable debug mode to output the SDK logs to Logcat:

// default is 'false'
val snsSdkBuilder = SNSMobileSDK.Builder(this).withDebug(true)
👍

Tip

Do not forget to disable the flag for the release build.

Custom logger

To also send the SDK logs to your own logger, pass it to .withLogTree. This works only in debug mode: without .withDebug(true), .withLogTree has no effect. For example:

class CustomTree : Logger {
    override fun d(tag: String, message: String, throwable: Throwable?) {
        Log.d(tag, message, throwable)
    }

    override fun e(tag: String, message: String, throwable: Throwable?) {
        Log.e(tag, message, throwable)
    }

    override fun i(tag: String, message: String, throwable: Throwable?) {
        Log.i(tag, message, throwable)
    }

    override fun v(tag: String, message: String, throwable: Throwable?) {
        Log.v(tag, message, throwable)
    }

    override fun w(tag: String, message: String, throwable: Throwable?) {
        Log.w(tag, message, throwable)
    }
}

Then pass it to the builder:

val snsSdkBuilder = SNSMobileSDK.Builder(this).withDebug(true).withLogTree(CustomTree())

Debug mode already writes to Logcat, so CustomTree above duplicates each line it receives.


Did this page help you?