zoukankan      html  css  js  c++  java
  • 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();
        }
    }
  • 相关阅读:
    STM32.ADC
    电源方案集
    什么叫二级域名
    android驱动学习---led实验
    Get,Post和Head具体解释
    Android 编码规范
    VC:当前不会命中断点,还没有为该文档载入不论什么符号
    经常使用的结构体
    【Facebook的UI开发框架React入门之九】button简单介绍(iOS平台)-goodmao
    记录遇到的ios下的bugs[废弃]
  • 原文地址:https://www.cnblogs.com/android-deli/p/10170067.html
Copyright © 2011-2022 走看看