Skip to content

CVeniamin/loglytics_library

Repository files navigation

loglytics-library

Release

Loglytics Android library project that works with jitpack.io.

https://jitpack.io/#CVeniamin/loglytics-library

Add it to your build.gradle with:

allprojects {
    repositories {
        maven { url "https://jitpack.io" }
    }
}

and:

dependencies {
    ...
    compile 'com.github.CVeniamin:loglytics-library:{latest version}'
}

Where {latest version} corresponds to tag version, e.g., v1.20

Adding a sample app

If you add a sample app to the same repo then your app needs to have a dependency on the library.
To do this in your app/build.gradle add:

    dependencies {
        compile project(':library')
    }

This Library only supports SDK Version >= 16 and was tested on Android Emulator devices with Android 6 and 7

Using Loglytics Platform

To use the library you only need to add the following code to your MainActivity.java.

    import io.loglytics.LoglyticsService;
    ...
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        ...
        String serverURL = "https://loglytics.herokuapp.com";
        LoglyticsService.start(this, serverURL);
        ...
    }

Make sure that you stop the service when destroying your Activity. For that add following code inside onDestroy() method.

    ...
    @Override
    protected void onDestroy() {
        super.onDestroy();
        ...
        LoglyticsService.stop(this);
        
    }

Then you need to create tag and pass a token to it, must be nested inside tag on AndroidManifest.xml as follows.
You can get this token after signup at https://loglytics.herokuapp.com

    <application
        ...
        <meta-data
            android:name="io.loglytics.token"
            android:value="YOUR_TOKEN_GOES_HERE"
            />
        ...
    </application>

Test Locally

If you wish you can test locally by having socketIO server with a nodeJS. Add following this to your MainActivity.java.
LoglyticsService.start() will use by default the following http://10.0.2.2:8080 address which represents localhost on android emulator.

   import io.loglytics.LoglyticsService;
       ...
       @Override
       protected void onCreate(Bundle savedInstanceState) {
           ...
           LoglyticsService.start(this);
           ...
       }

And having app.js as follows:

var http = require('http'),
    io   = require('socket.io');

var app = http.createServer();
app.listen(8080);

// Socket.IO server
var io = io.listen(app);

io.on('connection', function (socket) {

    socket.on('log', function (data, fn) {
        console.log(data);
    });

    socket.on('disconnect', function () {
        console.log("disconnected");
    });
});

Run it with:

node app.js

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages