封装的log工具类

一个封装好的log工具类,直接用了

package com.istv.ystframework.apkmanager.utils;
 
import android.util.Log;
 
/**
 * 一个具有开关的日志工具 代替系统的Log类
 * 
 * @LOGLEVEL 为0,不显示log
 * @LOGLEVEL 大于5,显示log
 * 
 */
public class Logger {
    private static int LOGLEVEL = 7;
    private static int VERBOSE = 1;
    private static int DEBUG = 2;
    private static int INFO = 3;
    private static int WARN = 4;
    private static int ERROR = 5;
 
    public static void v(String tag, String msg) {
        if (LOGLEVEL > VERBOSE)
            Log.v(tag, msg);
    }
 
    public static void d(String tag, String msg) {
        if (LOGLEVEL > DEBUG)
            Log.d(tag, msg);
    }
 
    public static void i(String tag, String msg) {
        if (LOGLEVEL > INFO)
            Log.i(tag, msg);
    }
 
    public static void w(String tag, String msg) {
        if (LOGLEVEL > WARN)
            Log.w(tag, msg);
    }
 
    public static void e(String tag, String msg) {
        if (LOGLEVEL > ERROR)
            Log.e(tag, msg);
    }
}

    原文作者:空白_c46e
    原文地址: https://www.jianshu.com/p/5bd8e6e4b1ff
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞