Open-source Log project for Android -- KLog

Source: Internet
Author: User

Open-source Log project for Android -- KLog

Log is frequently used during Android development and debugging. A good Log tool can save you a lot of time, so kaizige took the time to write this open-source project KLog, hope to help you improve development efficiency. This open-source library is inspired by Logger.

KLogd KLogdString KLogdTagString KLogjsonString Note: Use JCenter to reference why KLog sets the Log color Project address

KLog features support display of row numbers support display of function names of logs support printing without tags support click function names, jump to the execution File Location support JSON String Parsing print dependent library is very small, 200 lines of core code, only 4 k running demonstration

Usage Details

The following uses KLog. d () as an example. The following usage also applies

KLog. v () KLog. d () KLog. I () KLog. w () KLog. e () KLog. a () KLog. d ()

The "execute" is printed simply by using the method without parameters. The default Tag is the name of the current class.

KLog. d (String)

This method can be used to print normally. The default Tag is the name of the current class.

KLog. d (Tag, String)

This method is the same as what we use most frequently.

KLog. json (String)

This method can be used to print a string in JSON format. The Tag is the name of the current class by default.

KLog. json (Tag, String)

Like the above, the Tag only specifies

Notes

KLog printing is enabled by default. Disable the printing function of KLog in the official version.

We recommend that you use the following method to manage the KLog printing switch.

Add a custom field to BuildConfig.

public final class BuildConfig {  public static final boolean LOG_DEBUG = true;}

In build. gradle, configure the attribute values of the LOG_DEBUG field in the debug and release versions.

android {    buildTypes {        debug {            buildConfigField "boolean", "LOG_DEBUG", "true"        }        release {            buildConfigField "boolean", "LOG_DEBUG", "false"        }    }}

Initialize in Application

public class KLogApplication extends Application {    @Override    public void onCreate() {        super.onCreate();        KLog.init(BuildConfig.LOG_DEBUG);    }}
Use JCenter reference
dependencies {    compile 'com.github.zhaokaiqiang.klog:library:0.0.1'}
Why is it KLog?

"K" and "L" recently, you can click "KL" on the keyboard to directly call this class method to further improve efficiency.
"K" is also the first letter of "Kai" ^_^.

How to set the Log color

Save as to Save the topic, and then cancel "use inherited attributes" to set the desired color.

Project address

Click here. Welcome to star and follow, and submit the issue and pull request.

Respect Original, reprint Please note: From kaizi brother (http://blog.csdn.net/zhaokaiqiang1992) infringement must be studied!

Follow my weibo posts to get more exciting content

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.