A Log wrapper for Android applications, which simplifies and redefines the way of printing a 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.
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'
}
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.
Name | Version |
---|---|
targetSdkVersion | 24 |
minSdkVersion | 8 |
MIT License
Copyright (c) 2017 Yan QiDong