View on GitHub

ALog

A Log wrapper for Android applications.

Download this project as a .zip file Download this project as a tar.gz file

ALog

Travis Releases Bintray JitPack CodeCov VersionEye

A Log wrapper for Android applications, which simplifies and redefines the way of printing a log.

About Android Log

The order in terms of verbosity, from least to most is ERROR, WARN, INFO, DEBUG, VERBOSE. Verbose should never be compiled into an application except during development. Debug logs are compiled in but stripped at runtime. Error, warning and info logs are always kept.

Don’t print anything log if possible, especially after released!

If you still want to print logs, be careful.

Add Dependencies

From JCenter of Bintray:

dependencies {
    compile 'org.no_creativity.aar:ALog:0.4.0'
}

From JitPack:

allprojects {
    repositories {
        ..
        maven { url "https://jitpack.io" }
    }
}
dependencies {
    compile 'com.github.no-creativity:ALog:0.4.0'
}

Usage

The ALog should be extended like this:

public class A extends ALog {
    public static final String TAG = "YourGlobalTag";
    public static final ALog log = new A(TAG);

    private A(String tag) {
        super(tag, BuildConfig.DEBUG);
    }
}

And the class A should be used like this:

    // Print only when debug.
    A.log.v(); // Print the file and method name.
    A.log.d("Message"); // Print the message with the file and method name.

    // Print complicated information when debug.
    A.log.i(stringBuilder);
    A.log.i(set);
    A.log.i(map);

    // Print always.
    A.log.w("Message");
    A.log.e(exception); // Print the exception message.

    // Crash when debug, or print when release.
    A.log.wtf(exception); // Print stack traces.
    A.log.wtf("Message"); // Print the failure message.

Finally, the logs could be filtered like this:

adb logcat -s YourGlobalTag

You can find more detail in JavaDoc.

Version Information

GitHub tag commits-since

Name Version
targetSdkVersion 24
minSdkVersion 8

License

License

MIT License

Copyright (c) 2017 Yan QiDong