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;
        }
    }
  • 相关阅读:
    URL参数加密专用
    错误
    js学习类
    .net第一个服务器控件
    javascript中的call()和apply()方法 原创实例
    FIS使用技巧
    自定义参数表单URL参数处理
    避免编写解决"不存在"问题的代码
    从 1.1.0 升级到 1.2.0 的注意事项
    jquery常用插件,应用解析
  • 原文地址:https://www.cnblogs.com/jiayaguang/p/4371453.html
Copyright © 2011-2022 走看看