日志打印工具类

时间:2020-12-22 06:20:34
public class LogUtils {
//private static final int LOG_LEVEL = 6;
//我在这里做了调整,改成public,方便从外部设值,控制
public static int LOG_LEVEL = 6;

private static final int VERBOSE = 5;
private static final int DEBUG = 4;
private static final int INFO = 3;
private static final int WARN = 2;
private static final int ERROR = 1;

public static void v(String tag, String msg) {
if (LOG_LEVEL > VERBOSE) {
Log.v(tag, msg);
}
}

public static void d(String tag, String msg) {
if (LOG_LEVEL > DEBUG) {
Log.d(tag, msg);
}
}

public static void i(String tag, String msg) {
if (LOG_LEVEL > INFO) {
Log.i(tag, msg);
}
}

public static void w(String tag, String msg) {
if (LOG_LEVEL > WARN) {
Log.w(tag, msg);
}
}

public static void e(String tag, String msg) {
if (LOG_LEVEL > ERROR) {
Log.e(tag, msg);
}
}
}