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

Source: Internet
Author: User

1. API Highlights:

this API can be achieved without replacing APK . In the problem of mobile phone directly can catch effective log, can improve a lot of work efficiency.

2 , API Introduction

recently in the resolution of text messages. See a very powerful LOG switch ---log.isloggable

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

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

3. }

Enter the framework to see the definition of the isloggable method, and find that this is a JNI The method. Just the method declaration has very much stare.

Carefully looked down, found that this is Android to everyone's a gift.
The original meaning: check the current Tag is specified in the Log level.

The general default log level is info, which means that the log containing info will be output. You can change the default log level by setting the system Properties , and running the following command, for example:

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

You can also write this code in Local.prop file, and place the file in the /data/local.prop . Based on the instructions above. Try running the following command:

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

then a MMS test was sent. The valid log is lost.

We are doing some digging on this basis. See What surprises Google has left us. From the logtag.transaction in the second code above , you can see that there is a Logtag.java in the Mms package. file, and found that there are quite a few constants:

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, on theproblem of the phone directly can catch the effective log. Can improve a lot of 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 Application. There are Contacts and other important modules have been called, debugging these modules will be more convenient.

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

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.