LogDNA

Additional

Language
Kotlin
Version
1.1.0 (Oct 4, 2019)
Created
Feb 23, 2019
Updated
Dec 22, 2019 (Retired)
Owner
Mazen Rashed (mazenrashed)
Contributors
Mazen Rashed (mazenrashed)
bobpf
2
Activity
Badge
Generate
Download
Source code

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.

Already used by :

Cat® App: Fleet Management