There are generally two ways to manage log, and bloggers recommend using the first method below:
The first method:
The first step: Define a Logtools tool class, believe you can understand, whose log, can use whose name do method name, such as Logli, this is engineer Li print log
Copy Code code as follows:
Import Android.util.Log;
public class Logtools {
public static Boolean isshow = true;//Online mode
public static Boolean isshow = false;//Development mode
The log that ye engineers typed out
public static void Logye (String msg) {
if (isshow) {
LOG.I ("Ye", msg);
}
}
The log that the Li engineer typed out
public static void Logli (String msg) {
if (isshow) {
LOG.I ("Lili", MSG);
}
}
}
Step two: The way to apply in a program is:
Copy Code code as follows:
Logtools.logye ("ontouchevent-----" +event.getaction ());
The second method:
Log is often printed in development, but cannot be printed when we publish the item. In order to facilitate the operation of log we need to define a log class ourselves and then set the following log_level to 6 in the development phase so that all logs can be displayed, we set the Log_level to 0 when we release it. So the log is very easy to manage.
Copy Code code as follows:
public class Logger {
public static int log_level = 0;
public static int ERROR = 1;
public static int WARN = 2;
public static int INFO = 3;
public static int DEBUG = 4;
public static int verbos = 5;
public static void E (String tag,string msg) {
if (log_level>error)
LOG.E (tag, msg);
}
public static void W (String tag,string msg) {
if (Log_level>warn)
LOG.W (tag, msg);
}
public static void I (String tag,string msg) {
if (log_level>info)
LOG.I (tag, msg);
}
public static void D (String tag,string msg) {
if (Log_level>debug)
LOG.D (tag, msg);
}
public static void V (String tag,string msg) {
if (Log_level>verbos)
LOG.V (tag, msg);
}
}