• Android-LogUtil-工具类


    LogUtil-工具类 是专门Log日志打印 和 Toast的提示,的公共方法

    package common.library.utils;
    
    import android.content.Context;
    import android.util.Log;
    import android.widget.Toast;
    
    /**
     * @Author Liudeli
     * @Describe:Log日志级别打印相关工具类
     */
    public class LogUtil {
    
        private LogUtil(){}
    
        /**
         * 打印的信息日志信息
         */
        private final static String INFO = "☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻: ";
    
        /**
         * 打印的错误日志信息
         */
        private final static String ERROR = "✖✖✖✖✖✖✖✖✖✖✖✖✖✖✖✖✖✖✖✖✖✖✖✖✖✖: ";
    
        /**
         * 打印的调试日志信息
         */
        private final static String DEBUG = "☠☠☠☠☠☠☠☠☠☠☠☠☠☠☠: ";
    
        /**
         * 打印的全面日志信息
         */
        private final static String VERBOSE = "▂▂▂▃▃▄▄▅▅▆▆▆▇▇: ";
    
        /**
         * 打印的警告日志信息
         */
        private final static String WARN = "!!!!!!!!!!!!!!!!!!!!!!!!!!: ";
    
        /**
         * 打印information日志
         * @param tag 标签
         * @param msg 日志信息
         */
        public static void i(String tag,String msg){
            Log.i(tag, INFO + msg);
        }
    
        /**
         * 打印information日志
         * @param tag    标签
         * @param msg    日志信息
         * @param throwable    异常
         */
        public static void i(String tag, String msg, Throwable throwable){
            Log.i(tag, INFO + msg, throwable);
        }
    
        /**
         * 打印verbose日志
         * @param tag    标签
         * @param msg    日志信息
         */
        public static void v(String tag, String msg){
            Log.v(tag, VERBOSE + msg);
        }
    
        /**
         * 打印verbose日志
         * @param tag    标签
         * @param msg    日志信息
         * @param throwable    异常
         */
        public static void v(String tag, String msg, Throwable throwable){
            Log.v(tag, VERBOSE + msg, throwable);
        }
    
        /**
         * 打印debug信息
         * @param tag    标签信息
         * @param msg    日志信息
         */
        public static void d(String tag, String msg){
            Log.d(tag, DEBUG + msg);
        }
    
        /**
         * 打印debug日志
         * @param tag    标签信息
         * @param msg    日志信息
         * @param throwable    异常
         */
        public static void d(String tag, String msg, Throwable throwable){
            Log.d(tag, DEBUG + msg, throwable);
        }
    
        /**
         * 打印warn日志
         * @param tag    标签信息
         * @param msg    日志信息
         */
        public static void w(String tag, String msg){
            Log.w(tag, WARN + msg);
        }
    
        /**
         * 打印warn日志
         * @param tag    标签信息
         * @param msg    日志信息
         * @param throwable    异常
         */
        public static void w(String tag, String msg, Throwable throwable){
            Log.w(tag, WARN + msg, throwable);
        }
    
        /**
         * 打印error日志
         * @param tag
         * @param msg    标签
         */
        public static void e(String tag, String msg){
            Log.e(tag, ERROR + msg);
        }
    
        /**
         * 打印error日志
         * @param tag    标签
         * @param msg    日志信息
         * @param throwable    异常
         */
        public static void e(String tag, String msg, Throwable throwable){
            Log.e(tag, ERROR + msg, throwable);
        }
    
        /**
         * 吐司提示
         * @param msg
         */
        public static void toast(Context mContext, String msg) {
            Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show();
        }
    
        /**
         * 吐司提示 long类型
         * @param msg
         */
        public static void toastL(Context mContext, String msg) {
            Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show();
        }
    
        /**
         * 吐司提示 自定义时间类型
         * @param msg
         */
        public static void toastD(Context mContext, String msg, int duration) {
            Toast.makeText(mContext, msg, duration).show();
        }
    }
  • 相关阅读:
    python(十二)面向对象编程、类
    如何搭建测试环境
    python(十一)接口开发、写日志、发邮件、python来发请求、手动添加环境变量
    python(十):模块相关、操作Redis、操作Excel
    Python(九):递归+内置函数+第三方模块+md5加密+操作mysql
    Python(八) 函数、模块
    python练习题
    Python(七) 元组+集合+随机+string
    Python(六)操作文件+非空即真
    VUE基础-1
  • 原文地址:https://www.cnblogs.com/android-deli/p/10170067.html
Copyright © 2020-2023  润新知