Code Quality Rank: L5
Programming language: Java
License: MIT License
Tags: Utility    
Latest version: v4.1.7

puree-android alternatives and similar packages

Based on the "Utility" category.
Alternatively, view puree-android alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of puree-android or a related project?

Add another 'Utility' Package


Puree Build Status Android Arsenal Download


Puree is a log collector which provides the following features:

  • Filtering: Enable to interrupt process before sending log. You can add common params to logs, or the sampling of logs.
  • Buffering: Store logs to buffers and send them later.
  • Batching: Send logs in a single request with PureeBufferedOutput.
  • Retrying: Retry to send logs after backoff time if sending logs fails.


Puree helps you unify your logging infrastructure.


This is published on jcenter and you can use Puree as:

// build.gradle
buildscript {
    repositories {

// app/build.gradle
dependencies {
    compile 'com.cookpad.puree:puree:4.1.6'



Configure Puree with PureeConfiguration in Application#onCreate(), which registers pairs of what and where.

public class MyApplication extends Application {
    public void onCreate() {

    public static PureeConfiguration buildConfiguration(Context context) {
        PureeFilter addEventTimeFilter = new AddEventTimeFilter();
        return new PureeConfiguration.Builder(context)
                .pureeSerializer(new PureeGsonSerializer())
                .executor(Executors.newScheduledThreadPool(1)) // optional
                .register(ClickLog.class, new OutLogcat())
                .register(ClickLog.class, new OutBufferedLogcat().withFilters(addEventTimeFilter))

See also: [demo/PureeConfigurator.java](demo/src/main/java/com/example/puree/logs/PureeConfigurator.java)

Definition of PureeLog objects

Puree requires that clients supply an implementation of PureeSerializer to be able to serialize the logs. For instance, this is an implementation that uses Gson parser:

public class PureeGsonSerializer implements PureeSerializer {
    private Gson gson = new Gson();

    public String serialize(Object object) {
        return gson.toJson(object);

A log class is just a POJO whose properties are annotated following the requirements of the Json parser that you provided with PureeSerializer.

public class ClickLog {
    private String page;
    private String label;

    public ClickLog(String page, String label) {
        this.page = page;
        this.label = label;

You can use Puree.send() to send these logs to registered output plugins:

Puree.send(new ClickLog("MainActivity", "Hello"));
// => {"page":"MainActivity","label":"Hello"}

Definition of PureeOutput plugins

There are two types of output plugins: non-buffered and buffered.

  • PureeOutput: Non-buffered output plugins write logs immediately.
  • PureeBufferedOutput: Buffered output plugins enqueue logs to a local storage and then flush them in background tasks.

If you don't need buffering, you can use PureeOutput.

public class OutLogcat extends PureeOutput {
    private static final String TYPE = "out_logcat";

    public String type() {
        return TYPE;

    public OutputConfiguration configure(OutputConfiguration conf) {
        return conf;

    public void emit(JsonObject jsonLog) {
        Log.d(TYPE, jsonLog.toString());

If you need buffering, you can use PureeBufferedOutput.

public class OutFakeApi extends PureeBufferedOutput {
    private static final String TYPE = "out_fake_api";

    private static final FakeApiClient CLIENT = new FakeApiClient();

    public String type() {
        return TYPE;

    public OutputConfiguration configure(OutputConfiguration conf) {
        // you can change settings of this plugin
        // set interval of sending logs. defaults to 2 * 60 * 1000 (2 minutes).
        // set num of logs per request. defaults to 100.
        // set retry count. if fail to send logs, logs will be sending at next time. defaults to 5.
        return conf;

    public void emit(JsonArray jsonArray, final AsyncResult result) {
        // you have to call result.success or result.fail()
        // to notify whether if puree can clear logs from buffer
        CLIENT.sendLog(jsonArray, new FakeApiClient.Callback() {
            public void success() {

            public void fail() {

Definition of Filters

If you need to add common params to each logs, you can use PureeFilter:

public class AddEventTimeFilter implements PureeFilter {
    public JsonObject apply(JsonObject jsonLog) {
        jsonLog.addProperty("event_time", System.currentTimeMillis());
        return jsonLog;

You can make PureeFilter#apply() to return null to skip sending logs:

public class SamplingFilter implements PureeFilter {
    private final float samplingRate;

    public SamplingFilter(float samplingRate) {
        this.samplingRate = samplingRate;

    public JsonObject apply(JsonObject jsonLog) {
        return (samplingRate < Math.random() ? null : jsonLog);

Then register filters to output plugins on initializing Puree.

new PureeConfiguration.Builder(context)
        .register(ClickLog.class, new OutLogcat())
        .register(ClickLog.class, new OutFakeApi().withFilters(addEventTimeFilter, samplingFilter)


If you want to mock or ignore Puree.send() and Puree.flush(), you can use Puree.setPureeLogger() to replace the internal logger. See [PureeTest.java](puree/src/androidTest/java/com/cookpad/puree/PureeTest.java) for details.

Release Engineering

Set bintrayUser and bintrayKey in ~/.gradle/gradle.properties


and run the following tasks:

./gradlew clean connectedCheck assembleRelease bintrayUpload --info # dry-run
./gradlew assembleRelease bintrayUpload -PdryRun=false

See Also

Copyright (c) 2014 Cookpad Inc. https://github.com/cookpad

See [LICENSE.txt](LICENSE.txt) for the license.

*Note that all licence references and agreements mentioned in the puree-android README section above are relevant to that project's source code only.