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;
        }
    }
  • 相关阅读:
    二次离线莫队
    串串题-各种算法的应用
    插头dp 笔记
    ST03模拟赛#1 比赛记录
    AtCoder Regular Contest 123 比赛记录(vp)
    冷门trick:线性区间单调求和
    dp优化瞎吹
    概率期望
    NOI挑战赛#2 (vp) 记录
    动态规划-线性dp-序列组成-5833. 统计特殊子序列的数目
  • 原文地址:https://www.cnblogs.com/jiayaguang/p/4371453.html
Copyright © 2011-2022 走看看