• Android基础篇日志管理类


    /**
     * @author gongchaobin
     * 
     * 日志管理
     * [统一管理日志,包括各种级别的日志]
     */
    public class Log {
    
        /**
         * 控制日志开关
         */
        private static boolean LogSwitch = true;
        
        
        /**
         * 打印verbose级别的日志
         * 
         * @param tag 标记
         * @param text 日志内容
         */
        public static void verbose(String tag, String text)
        {
            if (LogSwitch) {
                android.util.Log.w(tag,
                        text);
            }
        }
    
        /**
         * 
         * 打印debug级别的日志<BR>
         * [功能详细描述]
         * 
         * @param obj tag标记,传入当前调用的类对象即可,方法会转化为该对象对应的类名
         * @param text 日志内容
         */
        public static void debug(Object obj, String text)
        {
            if (LogSwitch) {
                if (obj != null)
                {
                    debug(obj.getClass().getSimpleName(),
                        text);
                }
            }
        }
    
        /**
         * 打印debug级别的日志
         * 
         * @param tag 标记
         * @param text 日志内容
         */
        public static void debug(String tag, String text)
        {
            if (LogSwitch) {
                android.util.Log.d(tag,
                    text);
            }
        }
    
        /**
         * 打印info级别的日志
         * 
         * @param tag 标记
         * @param text 日志内容
         */
        public static void info(String tag, String text)
        {
            if (LogSwitch) {
                android.util.Log.i(tag,
                        text);
            }
    
        }
    
        /**
         * 打印warn级别的日志
         * 
         * @param tag 标记
         * @param text 日志内容
         */
        public static void warn(String tag, String text)
        {
            if (LogSwitch) {
                android.util.Log.w(tag,
                    text);
            }
        }
    
        /**
         * 打印warn级别的日志
         * 
         * @param tag 标记
         * @param text 日志内容
         * @param throwable 异常信息
         */
        public static void warn(String tag, String text, Throwable throwable)
        {
            if (LogSwitch) {
                android.util.Log.w(tag,
                    text,
                    throwable);
            }
        }
    
        /**
         * 打印error级别的日志
         * 
         * @param tag 标记
         * @param text 日志内容
         */
        public static void error(String tag, String text)
        {
            if (LogSwitch) {
                android.util.Log.e(tag,
                    text);
            }
        }
    
        /**
         * 打印error级别的日志
         * 
         * @param tag 标记
         * @param text 日志内容
         * @param throwable 异常信息
         */
        public static void error(String tag, String text, Throwable throwable)
        {
            if (LogSwitch) {
                android.util.Log.e(tag,
                    text,
                    throwable);
            }
        }
    
    }
  • 相关阅读:
    对一个或多个实体的验证失败。有关详细信息,请参阅“EntityValidationErrors”属性。
    Java基础学习笔记四 Java基础语法
    Java基础学习笔记一 Java介绍
    Java基础学习笔记二 Java基础语法
    Elasticsearch重要配置
    Elasticsearch配置
    Elasticsearch安装详解
    Elasticsearch文档查询
    Elasticsearch索引和文档操作
    Angular4项目,默认的package.json创建及配置
  • 原文地址:https://www.cnblogs.com/gongcb/p/2758310.html
Copyright © 2020-2023  润新知