zoukankan      html  css  js  c++  java
  • Android打印日志管理

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

    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;
        }
    }
  • 相关阅读:
    加密解密
    论事件驱动与异步IO
    linux 基础命令
    libgcc_s_dw2-1.dll 缺失问题解决
    TightVNC 远程桌面
    配置机器学习开发环境(eclipse + anaconda2)
    Caffe 执行python实例并可视化
    Caffe windows编译找不到python27_d.lib问题解决
    PHP 上传文件名中带中文的文件失败问题
    Windows 搭建PHP开发环境
  • 原文地址:https://www.cnblogs.com/jiayaguang/p/4371453.html
Copyright © 2011-2022 走看看