//log管理類,開發階段 level設爲verbose,記錄所有數據。
//上線後,將level設置爲nothing,屏蔽所有數據
//app維修,將level再次設置爲level,便於維修app
public class LogUtils {
public final static int verbose = 1;
public static final int debug = 2;
public static final int info = 3;
public static final int warn = 4;
public static final int error = 5;
public static final int nothing = 6;debug
public static final int level = verbose;開發
public static void verbose(String tag, String msg) {
if (level<=verbose) {
Log.v(tag, msg);
}
}
public static void debug(String tag, String msg) {
if (level<=debug) {
Log.d(tag, msg);
}
}
public static void info(String tag, String msg) {
if (level<=info) {
Log.i(tag, msg);
}
}
public static void warn(String tag, String msg) {
if (level<= warn) {
Log.w(tag, msg);
}
}
public static void error(String tag, String msg) {
if (level<=error) {
Log.e(tag, msg);
}
}class
}
bug
使用方式:方法
直接使用該類中的方法error
LogUtils.i("tag","記錄的數據");數據