日志打印工具类LogUtils

来源:互联网 发布:淘宝店铺申请 编辑:程序博客网 时间:2024/05/18 00:22
/** * 日志工具类: * 我们在项目中经常会打印日志,但是在项目上线后日志仍然会打印 * 这样会降低程序运行效率,因此需要在项目上线的时候把日志屏蔽掉 */public class LogUtils {    public static final 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 NOTING  = 6;    public static final int LEVEL   = VERBOSE;  // 项目上线后,将LEVEL = NOTING,就可以屏蔽所有日志了!    public static void v(String tag, String msg) {        if (LEVEL <= VERBOSE) {            Log.v(tag, msg);        }    }    public static void d(String tag, String msg) {        if (LEVEL <= DEBUG) {            Log.d(tag, msg);        }    }    public static void i(String tag, String msg) {        if (LEVEL <= INFO) {            Log.i(tag, msg);        }    }    public static void w(String tag, String msg) {        if (LEVEL <= WARN) {            Log.w(tag, msg);        }    }    public static void e(String tag, String msg) {        if (LEVEL <= ERROR) {            Log.e(tag, msg);        }    }}
1 0