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();
        }
    }
  • 相关阅读:
    20 个 .NET 6 新增的 API
    巅峰对决!Spring Boot VS .NET 6
    【.NET 遇上 GraphQL】 ChilliCream 平台介绍
    使用 CliWrap 让C#中的命令行交互举重若轻
    微软开源的Web测试和自动化神器 Playwright
    GraphQL 到底有什么魔力?
    win切换jdk版本
    WebBug Java漏洞靶场 Java代码审计
    Docker镜像安全的一些(初级)检测方法
    权限安全管控的设计想法
  • 原文地址:https://www.cnblogs.com/android-deli/p/10170067.html
Copyright © 2011-2022 走看看