Android: Share a very powerful Log switch---log.isloggable

Source: Internet
Author: User

1. API Highlights:

this API can be achieved without replacing APK , you can catch an effective device directly on the wrong phone . Log , can improve a lot of efficiency.

2 , API Introduction

recently, when solving the SMS problem, I saw a very powerful LOG Switch ---log.isloggable

1. if (log.isloggable (logtag.transaction, log.verbose)) {

2. log.v (TAG, "Creating transactionservice");

3. }

 EnterFrameworkView inisloggableThe definition of the method, found that this is a use of theJNIthe method. However, there are many comments on the method declaration. Carefully looked down and found that it wasAndroida present for everyone.
The original meaning: check the currentTagis specified in theLoglevel. The general defaultLoglevel isINFO, which means that this includesINFOof theLogwill be output. You can modify the default by setting the System PropertiesLoglevel, execute the following command:

1. setprop Log.tag.; your_log_tag>; Level

You can also write this code in Local.prop file, and put the file in the /data/local.prop . According to the instructions above, try to execute the following command:

1. adb shell SetProp log.tag.Mms:transaction VERBOSE

then sent a MMS test, effective Log have been lost.

We're doing some digging on this basis to see What surprises Google has left us with. From the logtag.transaction in the second code above , you can see that there is a logtag.java file in the Mms package. Found that there are quite a number of constants declared:

1. public static final String TRANSACTION = "Mms: Transaction ";

2. public static final String APP = "Mms:app";

3. public static final String thread_cache = "Mms:threadcache" ;

4. public static final String thumbnail_cache = "Mms: Thumbnailcache ";

5. public static final String pdu_cache = "Mms:pducache";

6. public static final String WIDGET = "Mms:widget";

7. public static final String contact = "Mms:contact" ;

This is all a multimedia message inside the important Log switch. Know these after debugging MMS is more convenient, do not change the APK, in the problem of the phone directly can catch the effective log, can improve a lot of work efficiency. Let's take a look at where isloggable (stringtag, int level) has been called, and found that in addition to the framework layer and Mms applications, as well as Contacts and other important modules have been called, and later debugging these modules will be much easier.

Android: Share a very powerful Log switch---log.isloggable

Related Article

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.