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)