All Projects → Drivemode → Timberlorry

Drivemode / Timberlorry

Licence: apache-2.0
Periodical log collector framework.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Timberlorry

Best Of Web Python
🏆 A ranked list of awesome python libraries for web development. Updated weekly.
Stars: ✭ 1,118 (+1568.66%)
Mutual labels:  library
Litter
Litter is a pretty printer library for Go data structures to aid in debugging and testing.
Stars: ✭ 1,137 (+1597.01%)
Mutual labels:  library
Cordova Plugin Test Framework
Apache Cordova
Stars: ✭ 66 (-1.49%)
Mutual labels:  library
Align
A general purpose application and library for aligning text.
Stars: ✭ 63 (-5.97%)
Mutual labels:  library
Logging Log4j2
Apache Log4j 2 is an upgrade to Log4j that provides significant improvements over its predecessor, Log4j 1.x, and provides many of the improvements available in Logback while fixing some inherent problems in Logback's architecture.
Stars: ✭ 1,133 (+1591.04%)
Mutual labels:  library
P5.clickable
Event driven, easy-to-use button library for P5.js 👆
Stars: ✭ 66 (-1.49%)
Mutual labels:  library
Whisper
Whisper is a file-based time-series database format for Graphite.
Stars: ✭ 1,121 (+1573.13%)
Mutual labels:  library
Hazelcast Cpp Client
Hazelcast IMDG C++ Client
Stars: ✭ 67 (+0%)
Mutual labels:  library
Poi
Mirror of Apache POI
Stars: ✭ 1,136 (+1595.52%)
Mutual labels:  library
Android Camera2 Library
Library to use Android Camera2 api easily.
Stars: ✭ 66 (-1.49%)
Mutual labels:  library
Sparkbutton
Android library to create buttons with Twitter's heart like animation.
Stars: ✭ 1,129 (+1585.07%)
Mutual labels:  library
Tus Java Server
Library to receive tus v1.0.0 file uploads in a Java server environment
Stars: ✭ 64 (-4.48%)
Mutual labels:  library
Dmxusb
DMXUSB emulates an ENTTEC-compatible DMXKing USB to DMX serial device with one, two, or n universes.
Stars: ✭ 66 (-1.49%)
Mutual labels:  library
Dotsloaderview
Simple dots loader view
Stars: ✭ 63 (-5.97%)
Mutual labels:  library
Evalne
Source code for EvalNE, a Python library for evaluating Network Embedding methods.
Stars: ✭ 67 (+0%)
Mutual labels:  library
Roffildlibrary
Library for MQL5 (MetaTrader) with Python, Java, Apache Spark, AWS
Stars: ✭ 63 (-5.97%)
Mutual labels:  library
Bubbles
⚡️A library for adding messenger style floating bubbles to any android application 📲
Stars: ✭ 66 (-1.49%)
Mutual labels:  library
Notifier
Notifications library made with VanillaJS.
Stars: ✭ 67 (+0%)
Mutual labels:  library
Markdown Builder
1kb Markdown builder for Node.js
Stars: ✭ 67 (+0%)
Mutual labels:  library
Stereo
A Flutter plugin for playing music on iOS and Android.
Stars: ✭ 66 (-1.49%)
Mutual labels:  library

TimberLorry

Gitter Android Arsenal License Circle CI

Periodical log collector framework.

Timber Lorry
Photo Licensed under CC BY-NC 2.0 by jbdodane

Usage

In your Application, initialize TimberLorry with configuration on your preference. After this, you can schedule periodical log collection.

public class TimberLorryApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        TimberLorry.initialize(new Config.Builder()
                .collectIn(10) // collect log data every 10 seconds.
                .serializeWith(new GsonSerializer())
                .addOutlet(new LogcatOutlet()).build(this));
        TimberLorry.getInstance().schedule();
    }
}

How TimberLorry works

TimberLorry is a log collector without data loss for some reasons(e.g. reboot, exit application). TimberLorry will store logs in the buffer(internal database by default), and periodically send it to an endpoint. If no internet connection available, the periodical work will not executed.

Building Blocks

TimberLorry has some gateways to customize payloads, serialization logic, and buffer storage, and log endpoint. All customization will be injected with Config object.

Custom Payload

Payload is an entity object containing log data. The following snippet shows an example code.

public class ButtonClick implements Payload {
    private final long timeInMillis;

    public ButtonClick(long timeInMillis) {
        this.timeInMillis = timeInMillis;
    }
}

Payloads will be serialized by Serializer in the buffer.

Custom Serializer

You can add your own serializer.

Here is an example using Gson.

public class GsonSerializer implements Serializer {
    @Override
    public String serialize(Payload payload) {
        return new Gson().toJson(payload);
    }
}

We have this GsonSerializer in plug project.

Custom BufferResolver

If you would like to use another log data storage(e.g. internal storage, shared preferences), you can implement your own BufferResolver.

public class SharedPrefBufferResolver extends AbstractBufferResolver {
    private final Application application;

    public SharedPrefBufferResolver(Application application, @NonNull AccountManager accountManager, @NonNull ContentResolver resolver, Account account) {
        super(accountManager, resolver, account);
        this.application = application;
    }

    @Override
    public void save(Serializer serializer, Payload payload) {
        Record record = new Record(payload.getClass(), serializer.serialize(payload));
        // ... write record on the preference.
    }

    @Override
    public void save(Serializer serializer, Payload... payloads) {
        for (Payload payload : payloads) {
            Record record = new Record(payload.getClass(), serializer.serialize(payload));
            SharedPreferences pref = SharedPreferences.getDefaultSharedPreferences(application);
            // ... write record on the preference.
        }
    }

    @Override
    public List<Record> fetch() {
        List<Record> records = new ArrayList<>();
        SharedPreferences pref = SharedPreferences.getDefaultSharedPreferences(application);
        // ... find records on the preference and convert them to Record.
        return records;
    }

    @Override
    public void remove(Record record) {
        SharedPreferences pref = SharedPreferences.getDefaultSharedPreferences(application);
        // ... find record on the preference and remove it.
    }

    @Override
    public void clear() {
        SharedPreferences pref = SharedPreferences.getDefaultSharedPreferences(application);
        pref.edit().clear().apply();
    }
}

Custom Log Endpoint

You can add log endpoint with custom Outlet. If you want to filter Payload in your Outlet, check the Payload class information in Outlet#accept(Class<?>) and return true if you accept the Payload in this Outlet.

public class LogcatOutlet implements Outlet {
    public static final String TAG = LogcatOutlet.class.getSimpleName();

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean accept(Class<?> payload) {
        return true; // every payload is logged with this outlet
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Result dispatch(String payload) {
        // do thread blocking work here :)
        // if something went wrong here, catch the exception here and envelope it into Result object to return.
        Utils.logV(payload);
        return Result.success();
    }

    @Override
    public String name() {
        return "LogCat";
    }
}

Plugins

We have some customizations in "plug" project as plugin by default. Currently in "plug" project, following plugins are provided.

Download

Via Gradle

dependencies {
    compile 'com.drivemode:TimberLorry:[email protected]'
    compile 'com.drivemode:TimberLorry-Plug:[email protected]' // this is an optional
}

License

Copyright (C) 2015 Drivemode, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].