Learn how to use the Log tool for Android (19)

Source: Internet
Author: User

Usually we need to add log in the project to print some information, if in the project random view log information, or want to print only log of the different levels of log information, as well as the project release, the need to clear the log information, so that the workload is particularly large, So we typically build a tool class that prints log information:


public class LogCat {private static final int log_level = 5;private static final Boolean open_log=false;public static void I (string tag, string msg) {if (Log_level > 2 && open_log) {log.i (tag, msg);}} public static void E (string tag, string msg) {if (Log_level > 0 && open_log) {LOG.E (tag, msg);}} public static void W (string tag, string msg) {if (Log_level > 1 && open_log) {LOG.W (tag, msg);}} public static void D (string tag, string msg) {if (Log_level > 3 && open_log) {LOG.D (tag, msg);}} public static void V (string tag, string msg) {if (Log_level > 4 && open_log) {LOG.V (tag, msg);}}}

In this case we can change the Boolean value of the Open_log to turn on or off the display of the log information, or change the log level and print it by changing the log_level.


Reprint Please specify source:http://blog.csdn.net/hai_qing_xu_kong/article/details/44056193 Emotional Control _


Learn how to use the Log tool for Android (19)

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.