Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Android kotlin send debug log as slack message


import com.github.kittinunf.fuel.Fuel
import com.github.kittinunf.fuel.android.extension.responseJson
import org.json.JSONObject
import timber.log.Timber

object RemoteLogger {
    const val SLACK_WEBHOOK_URL = "https://hooks.slack.com/services/XXXXXXXX/XXXXXXX";
    fun sendSlackLog(message: String) {
        try {
            val json = JSONObject()
            json.put("text", message)

            Fuel.post(SLACK_WEBHOOK_URL)
                    .header("Content-type" to "application/json")
                    .body(json.toString())
                    .responseJson() { request, response, result ->
                Timber.d("Debug Slack Response ${result.toString()}")
            }

        } catch (e: Exception) {
            Timber.d("Debug Slack Error + ${e.toString()}")
        } finally {
        }
    }
}
 
PREVIOUS NEXT
Tagged: #Android #kotlin #send #debug #log #slack #message
ADD COMMENT
Topic
Name
4+3 =