Logging

SDK logs are disabled by default. You can enable logs and set a log level when initializing ChatClient.

You can set logs at the following levels:

  • ChatLogLevel.ALL to see all log entries.
  • ChatLogLevel.DEBUG to see debug, warning, and error entries.
  • ChatLogLevel.WARN to see warning and error entries.
  • ChatLogLevel.ERROR to see error entries.
  • ChatLogLevel.NOTHING to not show any logs.
val client = ChatClient.Builder("apiKey", context)
    .logLevel(ChatLogLevel.ALL)
    .build()

You should only enable logging in development builds.

Intercepting Logs

To intercept logs from the SDK, you can also pass in your own ChatLoggerHandler:

val client = ChatClient.Builder("apiKey", context)
    .logLevel(ChatLogLevel.ALL)
    .loggerHandler(object : ChatLoggerHandler {
        override fun logT(throwable: Throwable) {
            // custom logging
        }

        override fun logT(tag: Any, throwable: Throwable) {
            // custom logging
        }

        override fun logI(tag: Any, message: String) {
            // custom logging
        }

        override fun logD(tag: Any, message: String) {
            // custom logging
        }

        override fun logW(tag: Any, message: String) {
            // custom logging
        }

        override fun logE(tag: Any, message: String) {
            // custom logging
        }

        override fun logE(tag: Any, message: String, throwable: Throwable) {
            // custom logging
        }
    })
    .build()

Filtering Logs

All SDK log tags have Chat: as a prefix that you can use when filtering logs.

adb logcat com.your.package | grep "Chat:"

Here’s a set of useful tags for debugging network communication:

  • Chat:Http to see HTTP requests made from the ChatClient and the responses returned by Stream.
  • Chat:Events to see a list of events that the ChatClient emits.
  • Chat:Socket to see socket related events.
© Getstream.io, Inc. All Rights Reserved.