package com.huawei.network.ott.weixin.util;

import android.util.Log;

public final class DebugLog {

	/**
* 描述级别的日志标识,该级别为日志最低级别,发布时将关闭
*/
public static final int VERBOSE = 0;
/**
* 调试级别的日志标识,主要用于打印调试信息,发布时将关闭
*/
public static final int DEBUG = 1;
/**
* 信息级别的日志标识,主要用于打印数据,属性等信息,发布时将关闭
*/
public static final int INFO = 2;
/**
* 警告级别的日志标识,主要用于打印警告,发布时不关闭
*/
public static final int WARN = 3;
/**
* 错误级别的日志标识,主要用于打印错误,发布时不关闭
*/
public static final int ERROR = 4; private static boolean isPrintLog = true; private static int logLevel = VERBOSE; /**
* 是否打印日志
*
* @return
*/
public static boolean isPrintLog() {
return isPrintLog;
} /**
* 设置是否打印日志
*
* @param isPrintLog
* 如果设置为true,则打印日志,否则将不打印日志
*/
public static void setPrintLog(boolean isPrintLog) {
DebugLog.isPrintLog = isPrintLog;
} /**
* 获取当前日志的打印最低Level
*
* @return
*/
public static int getLogLevel() {
return logLevel;
} /**
* 设置当前日志的打印最低Level
*
* @param logLevel
*/
public static void setLogLevel(int logLevel) {
DebugLog.logLevel = logLevel;
} /**
* 打印一个 {@link #VERBOSE} 日志信息。
*
* @param tag
* Used to identify the source of a log message. It usually
* identifies the class or activity where the log call occurs.
* @param msg
* The message you would like logged.
*/
public static int v(String tag, String msg) {
if (isPrintLog && VERBOSE >= logLevel) {
return Log.v(tag, msg);
} else {
return -1;
}
} /**
* 打印一个 {@link #VERBOSE} 日志信息并打印异常信息。
*
* @param tag
* Used to identify the source of a log message. It usually
* identifies the class or activity where the log call occurs.
* @param msg
* The message you would like logged.
* @param tr
* An exception to log
*/
public static int v(String tag, String msg, Throwable tr) {
if (isPrintLog && VERBOSE >= logLevel) {
return Log.v(tag, msg, tr);
} else {
return -1;
}
} /**
* 打印一个 {@link #DEBUG} 日志信息。
*
* @param tag
* Used to identify the source of a log message. It usually
* identifies the class or activity where the log call occurs.
* @param msg
* The message you would like logged.
*/
public static int d(String tag, String msg) {
if (isPrintLog && DEBUG >= logLevel) {
return Log.d(tag, msg);
} else {
return -1;
}
} /**
* 打印一个 {@link #DEBUG} 日志信息并打印异常信息。
*
* @param tag
* Used to identify the source of a log message. It usually
* identifies the class or activity where the log call occurs.
* @param msg
* The message you would like logged.
* @param tr
* An exception to log
*/
public static int d(String tag, String msg, Throwable tr) {
if (isPrintLog && DEBUG >= logLevel) {
return Log.d(tag, msg, tr);
} else {
return -1;
}
} /**
* 打印一个 {@link #INFO} 日志信息。
*
* @param tag
* Used to identify the source of a log message. It usually
* identifies the class or activity where the log call occurs.
* @param msg
* The message you would like logged.
*/
public static int i(String tag, String msg) {
if (isPrintLog && INFO >= logLevel) {
return Log.i(tag, msg);
} else {
return -1;
}
} /**
* 打印一个 {@link #INFO} 日志信息并打印异常信息。
*
* @param tag
* Used to identify the source of a log message. It usually
* identifies the class or activity where the log call occurs.
* @param msg
* The message you would like logged.
* @param tr
* An exception to log
*/
public static int i(String tag, String msg, Throwable tr) {
if (isPrintLog && INFO >= logLevel) {
return Log.i(tag, msg, tr);
} else {
return -1;
}
} /**
* 打印一个 {@link #WARN} 日志信息。
*
* @param tag
* Used to identify the source of a log message. It usually
* identifies the class or activity where the log call occurs.
* @param msg
* The message you would like logged.
*/
public static int w(String tag, String msg) {
if (isPrintLog && WARN >= logLevel) {
return Log.w(tag, msg);
} else {
return -1;
}
} /**
* 打印一个 {@link #WARN} 异常信息。
*
* @param tag
* Used to identify the source of a log message. It usually
* identifies the class or activity where the log call occurs.
* @param msg
* The message you would like logged.
*/
public static int w(String tag, Throwable tr) {
if (isPrintLog && WARN >= logLevel) {
return Log.w(tag, tr);
} else {
return -1;
}
} /**
* 打印一个 {@link #WARN} 日志信息并打印异常信息。
*
* @param tag
* Used to identify the source of a log message. It usually
* identifies the class or activity where the log call occurs.
* @param msg
* The message you would like logged.
* @param tr
* An exception to log
*/
public static int w(String tag, String msg, Throwable tr) {
if (isPrintLog && WARN >= logLevel) {
return Log.w(tag, msg, tr);
} else {
return -1;
}
} /**
* 打印一个 {@link #ERROR} 日志信息。
*
* @param tag
* Used to identify the source of a log message. It usually
* identifies the class or activity where the log call occurs.
* @param msg
* The message you would like logged.
*/
public static int e(String tag, String msg) {
if (isPrintLog && ERROR >= logLevel) {
return Log.e(tag, msg);
} else {
return -1;
}
} /**
* 打印一个 {@link #ERROR} 日志信息并打印异常信息。
*
* @param tag
* Used to identify the source of a log message. It usually
* identifies the class or activity where the log call occurs.
* @param msg
* The message you would like logged.
* @param tr
* An exception to log
*/
public static int e(String tag, String msg, Throwable tr) {
if (isPrintLog && ERROR >= logLevel) {
return Log.e(tag, msg, tr);
} else {
return -1;
}
} }

  

好用的log打印类的更多相关文章

  1. python 以单例模式封装logging相关api实现日志打印类

    python 以单例模式封装logging相关api实现日志打印类   by:授客QQ:1033553122 测试环境: Python版本:Python 2.7   实现功能: 支持自由配置,如下lo ...

  2. Android日志打印类LogUtils,能够定位到类名,方法名以及出现错误的行数并保存日志文件

    Android日志打印类LogUtils,能够定位到类名,方法名以及出现错误的行数并保存日志文件 在开发中,我们常常用打印log的方式来调试我们的应用.在Java中我们常常使用方法System.out ...

  3. tiny4412 串口驱动分析七 --- log打印的几个阶段之内核启动阶段(earlyprintk)

    作者:彭东林 邮箱:pengdonglin137@163.com 开发板:tiny4412ADK+S700 4GB Flash 主机:Wind7 64位 虚拟机:Vmware+Ubuntu12_04 ...

  4. Android4_学会使用Log打印

    一.Log介绍: Android中的日志工具类是Log(android.util.Log),这个类中提供了如下5个方法来供我们打印日志. Log.v() .用于打印那些最为琐碎的.意义最小的日志信息. ...

  5. JS高级群的日常!写一个从10到0的倒计时,用console.log打印,不可以用 setInterval!本来说好的研究avalonJS最后演变成了看着大神在那边互相比拼实力。。

      JS高级群的日常!写一个从10到0的倒计时,用console.log打印,不可以用 setInterval!本来说好的研究avalonJS最后演变成了看着大神在那边互相比拼实力..   小森执行一 ...

  6. [asp.net]c# winform打印类

    using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using ...

  7. -XX:-PrintClassHistogram 按下Ctrl+Break后,打印类的信息

    -XX:+PrintClassHistogram –按下Ctrl+Break后,打印类的信息: num     #instances         #bytes  class name ------ ...

  8. 关于Debug下的Log打印问题

    在项目中为了调试经常会用到Log打印,比如打印当前方法__func__, 对象,地址等等,所以项目最后每次运行调试控制台满满的都是打印日志,到release发布的时候,显然不太合适,这里其实可以用一个 ...

  9. javascript篇-console.log()打印object却显示为字符串[object object]

    console.log打印对象遇到的一个问题,如下截图 打印结果与预期不符,原因是因为字符串‘a’和对象object拼接在一起,拼成了一个字符串

随机推荐

  1. 封装一个漂亮的ant design form标签组件

    在ant design 的form组件中 能用于提交的组件比较少,所以我在这写了一个可以单选.多选标签提交的组件,调用非常简单. 代码: import React,{Fragment} from 'r ...

  2. turtle库常用命令

    一, 海龟动作: 移动和绘制 forward()| fd() 前进多少 backward()|bk()|back()后退 right()|rt() 右转多少度 left() 左转多少度 goto()| ...

  3. python 在linux上面安装beautifulsoup4(bs4) No module named 'bs4'

    续费了我的服务器 重做系统成了Linux服务器 然后想把Windown上的Python脚本放上去运行 但是出现了 No module named 'bs4' 的问题 pip install bs4 试 ...

  4. 吴裕雄 python 机器学习——数据预处理流水线Pipeline模型

    from sklearn.svm import LinearSVC from sklearn.pipeline import Pipeline from sklearn import neighbor ...

  5. Android学习08

    PopupWindow PopupWindow用来实现一个弹出框,可以使用任意布局的View作为其内容,这个弹出框是悬浮在当前activity之上的. 1.弹出框的布局:画一个PopupWindow的 ...

  6. 【MySQL】完整性约束

    " 目录 not null default unique 单列唯一 联合唯一 primary key 单列主键 复合主键 auto_increment 步长与偏移量 foreign key ...

  7. 【jQuery基础】

    " 目录 #. 介绍 1. 优势 2. 版本 3. jQuery对象 #. 查找标签 1.  选择器 /. 基本选择器 /. 层级选择器 /. 基本筛选器 /. 使用jQuery实现弹框 / ...

  8. Navicat连接两个不同机子上的mysql数据库,端口用换吗?--不用

    经过了上一篇的努力,成功的连上了远程的mysql数据库 dos 命令行下的成功连接 在用Navicat连接的时候要注意: 端口仍然是3306,而不用去更改,并不会和上面的本机的Mysql连接使用的端口 ...

  9. Introducing .NET 5

    Today, we’re announcing that the next release after .NET Core 3.0 will be .NET 5. This will be the n ...

  10. Spring Boot Thymeleaf 模板引擎的使用

    Spring Boot 中可以支持很多模板引擎,Thymeleaf 是 Spring Boot 官方推荐使用的模板引擎,虽然在社区 Thymeleaf 的性能被许多人所吐糟,但这仍然不影响大量的开发人 ...