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. php中的elseif和else if

    以前的时候还没注意到,知道进入公司,看的代码多了点,时常看到elseif的分支,而我自己时常用的是else if,于是就注意到,他们既然都可以用,那么他们的却别在哪儿呢? 通过查询,原来,确实有点小小 ...

  2. Go语言内置包之strconv

    文章引用自 Go语言内置包之strconv Go语言中strconv包实现了基本数据类型和其字符串表示的相互转换. strconv包 strconv包实现了基本数据类型与其字符串表示的转换,主要有以下 ...

  3. 关于this和base的区别

    一句话总结:在有冲突得时候,base和this能够进行区分,在没有冲突得时候,是一样得. 基于成员调用 基于构造方法 参考: http://www.cnblogs.com/reommmm/archiv ...

  4. Kosaraju's algorithm

    推荐到我的这篇博客中看完整版的. 该算法用于求解有向图的强连通分量,也就是强连通子图的个数. 算法实现摘自Kosaraju's algorithm - 百度百科: #include <iostr ...

  5. (二)tensorflow-gpu2.0之自动导数

    import tensorflow as tf ''' 梯度:导数或偏导数 1.在什么点的导数:在点(a,b,c,w)=(1,2,3,4)点的导数 2.梯度环境 对谁求导: 对w求导 函数: y = ...

  6. Java JDBC 数据库链接小结随笔

    Java JDBC 数据库链接小结随笔 一.链接数据库的步骤 二.关于Statement  和  PrepareStatement 两者区别 用法 三.关于 ResultSet 的一些小结 四.自定义 ...

  7. 微服务架构中的Redis

    了解如何将Redis与Spring Cloud和Spring Data一起使用以提供配置服务器,消息代理和数据库. Redis可以广泛用于微服务架构中.它可能是少数流行的软件解决方案之一,你的应用程序 ...

  8. 4_6 师兄帮帮忙(UVa12412)(选做)

    你好,我是外国语学院的本科生.正如你所知道的,编程是一个  在我们大学必修课,即使他/她的专业是远离计算机科学.我根本不喜欢这个 课程,因为我不擅长电脑,我不想有任何编程的尝试!  但我不得不做作业: ...

  9. NOIP2016换教室 BZOJ 4720

    BZOJ 4720 换教室 题目描述: 对于刚上大学的牛牛来说,他面临的第一个问题是如何根据实际情况申请合适的课程.在可以选择的课程中,有2n节 课程安排在n个时间段上.在第i(1≤i≤n)个时间段上 ...

  10. C++11⾥⾯很好⽤的auto声明

    本文摘录于柳神笔记: auto 是C++11⾥⾯的新特性,可以让编译器根据初始值类型直接推断变量的类型.⽐如这样: 当然这个在算法⾥⾯最主要的⽤处不是这个,⽽是在STL中使⽤迭代器的时候, auto ...