Android Kotlin mengirim log debug sebagai pesan kendur
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 {
}
}
}
Uen X