LogDNA

Additional

Language
Kotlin
Version
1.0.1 (Feb 25, 2019)
Created
Feb 23, 2019
Updated
Mar 3, 2019
Owner
Mazen Rashed (mazenrashed)
Contributor
Mazen Rashed (mazenrashed)
1
Activity
Badge
Generate
Download
Source code

Advertising

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)

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}")  
}