In the process of Android development and debugging, the use of log is very frequent, a good log tool can save you a lot of time, so klog to write an open source project, hoping to help you improve the efficiency of development, this open source library is inspired by logger
- Features of Klog
- Run the Demo
- Use the detailed
- KLogd
- Klogdstring
- Klogdtagstring
- Klogjsonstring
- Klogjsontagstring
- Precautions
- Using Jcenter references
- Why is it called Klog?
- How to set the color of a log
- Project Address
Features of Klog
- Support for displaying line numbers
- Supports displaying log function name
- Support for no tag printing
- Support click function name, jump to execute file location
- Supports JSON string parsing printing
- Dependent libraries are very small, core code 200 lines, only 4 K
Run the Demo
Use the detailed
The following usage applies to KLOG.D () as an example.
- KLOG.V ()
- KLOG.D ()
- KLOG.I ()
- KLOG.W ()
- KLOG.E ()
- KLOG.A ()
KLOG.D ()
With a parameterless method, the "execute" is simply printed, and the default tag is the name of the current class
KLOG.D (String)
Using this method, you can print normally, the default tag is the name of the current class
KLOG.D (tag,string)
This method is the same as the one we used most.
Klog.json (String)
Use this method to print a JSON-formatted string, and tag implicitly considers the name of the current class
Klog.json (tag,string)
The same as above, but tag himself specified
Precautions
The print function of Klog is turned on by default, please turn off the klog print function in the official version.
It is recommended to manage the Klog print switch in the following way.
Add a custom field in Buildconfig.
publicfinalclass BuildConfig { publicstaticfinalbooleantrue;}
In Build.gradle, configure the Log_debug field in the Debug version and release version of the property values.
android { buildTypes { debug { "boolean""LOG_DEBUG""true" } release { "boolean""LOG_DEBUG""false" } }}
Initialize in application
publicclass KLogApplication extends Application { @Override publicvoidonCreate() { super.onCreate(); KLog.init(BuildConfig.LOG_DEBUG); }}
Using Jcenter references
{ compile ‘com.github.zhaokaiqiang.klog:library:0.0.1‘}
Why is it called Klog?
"K" and "L" recently, click on the keyboard "KL" can directly call this class method, further improve efficiency.
"K" is also the first letter of "Kay" ^_^.
How to set the color of a log
If you want to save the theme with "Save as" and then cancel "use inherited Attributes", you can set your desired color
Project Address
Please click here to welcome star and follow, as well as submit issue and pull request.
Respect the original, reproduced please specify: from Kaizico (http://blog.csdn.net/zhaokaiqiang1992) infringement must investigate!
Follow my Weibo to get more content
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
"Kyle takes you to learn Android" Android dedicated log open source project--klog