首页 > 移动平台 > 详细

Android打印日志管理

时间:2015-03-27 14:18:45      阅读:185      评论:0      收藏:0      [点我收藏+]

做项目的时候,免不了要打印许多日志,等项目上线了,想要去除日志是又找不到在哪里怎么办?我们可以建立一个日志打印的类来统一管理;

public class LogUtil {
    public static final String TAG = "project name";
    public static boolean isDebug = true;
    public static boolean isInfo = true;
    public static boolean isWarn = true;
    public static boolean isError = true;

    public static void d(String tag, String msg) {
        if (isDebug)
            android.util.Log.d(tag, msg);
    }

    public static void d(String tag, String msg, Throwable t) {
        if (isDebug)
            android.util.Log.d(tag, msg, t);
    }

    public static void i(String tag, String msg) {
        if (isInfo)
            android.util.Log.i(tag, msg);
    }

    public static void i(String tag, String msg, Throwable t) {
        if (isInfo)
            android.util.Log.i(tag, msg, t);
    }

    public static void w(String tag, String msg) {
        if (isWarn)
            android.util.Log.w(tag, msg);
    }

    public static void w(String tag, String msg, Throwable t) {
        if (isWarn)
            android.util.Log.w(tag, msg, t);
    }

    public static void e(String tag, String msg) {
        if (isError)
            android.util.Log.e(tag, msg);
    }

    public static void e(String tag, String msg, Throwable t) {
        if (isError)
            android.util.Log.e(tag, msg, t);
    }
    public static void isDebugAll(boolean isTure){
        isDebug=isTure;
        isInfo = isTure;
        isWarn = isTure;
        isError = isTure;
    }
}

 

Android打印日志管理

原文:http://www.cnblogs.com/jiayaguang/p/4371453.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!