LogDNA-Android-Client
Android client for LogDNA
Add the JitPack repository to your build file
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add dependency
dependencies {
implementation 'com.github.mazenrashed:LogDNA-Android-Client:${LAST_VERSION}'
}
Add permissions to manifest
<uses-permission android:name="android.permission.INTERNET" />
Initialize LogDNA
Should be initialized once in Application.onCreate()
:
LogDna.init(LOG_DNA_API_KEY, APP_NAME, HOST_NAME)
Start Logging
LogDna.log(
Line.Builder().setLine("Some Test")
.addCustomField(Line.CustomField("fName", "mazen"))
.addCustomField(Line.CustomField("lName", "rashed"))
.addCustomField(Line.CustomField("age", 25))
.setLevel(Line.LEVEL_DEBUG)
.setTime(System.currentTimeMillis())
.build()
)
Listen to your logs
Using callback
LogDna.logResultsListener = { logResult ->
Log.d("LogDna", "${logResult.isSuccessful}, ${logResult.message}, ${logResult.logRequest.uid}")
}
Using RxJava / RxKotlin
Add RxRelay dependency
dependencies {
implementation 'com.jakewharton.rxrelay2:rxrelay:2.1.0'
}
Then subscribe to logResults
LogDna.logResults.subscribe { logResult ->
Log.d("LogDna", "${logResult.isSuccessful}, ${logResult.message}, ${logResult.logRequest.uid}")
}
Contributing
We welcome contributions to LogDNA Android Client !
- ⇄ Pull requests and ★ Stars are always welcome.