Skip to content

no-creativity/ALog

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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:

  • Add it in your root build.gradle at the end of repositories:
allprojects {
    repositories {
        ..
        maven { url "https://jitpack.io" }
    }
}
  • Add the dependency:
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

About

A Log wrapper for Android applications.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages