Horje
Android kotlin send debug log as slack message Code Example
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 {
        }
    }
}




Java

Related
code to close dialog containg layout Code Example code to close dialog containg layout Code Example
Aggregation in java Code Example Aggregation in java Code Example
processing java screen wrap Code Example processing java screen wrap Code Example
Does JVM create object of Main class (the class with main())? Code Example Does JVM create object of Main class (the class with main())? Code Example
Lists - removing Code Example Lists - removing Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
6