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. 读书笔记 - 把时间当作朋友 by 李笑来

    要管理的不是时间,而是自己. 摸着石头渐行渐远,最终也能过河.- 朱敏 赛伯乐(中国)投资公司 董事长 一切都靠积累,一切都可提前准备,越早醒悟越好.人的一生是奋斗的一生,但是有的人一生过得很伟大,有 ...

  2. Linux-VMware 15 虚拟机黑屏问题

    VMware 15 虚拟机黑屏问题   最近终于舍弃win7,换了win10的操作系统...   VM12不兼容,各种问题频出,于是换了VM15. 新装了kali2019.03,结果刚装好不久,在某一 ...

  3. WordPress 安装教程

    1.要安装WordPress,先看他的环境要求 2.环境符合后,直接去官网下载 WordPress(点击去官网) 下载最新的安装包 3.下载解压后,直接在浏览器中访问 会自动跳转到安装界面 http: ...

  4. appium可通过SDK自带的uiautomatorviewer或monitor工具,来查看页面元素(Android)

    工具一:uiautomatorviewer 1.在SDK的tools目录中找到uiautomatorviewer,双击打开若出现闪退一般是jdk版本不匹配(建议安装jdk1.8的): 2.在使用这个工 ...

  5. excel表格 筛选 通过mysql语句

    1.整理excel表格的数据 类似的 前面有其他符号的 都可以处理. 注意下一步是2个操纵:分别设置左右: 结果: 2.在复制粘贴到excel的时候,会有一些数字被设置成了科学计数法, 例如复制到ex ...

  6. Python 输入与输出

    Python2版本 raw_input raw_input("输入提示"),会把输入的内容当做字符串返回 input 会把用户输入的内容当做代码来处理,可以理解为 raw_inpu ...

  7. 多进程 多进程queue

    多进程 import multiprocessing import threading import time def thread_run(): print(threading.get_ident( ...

  8. es 分词器介绍

    按照单词切分,不做处理 GET _analyze { "analyzer": "standard", "text": "2 run ...

  9. ServerSuperIO开发记录

    1.需要编写DriverCommand来支撑协议驱动,实现ProtocolCommand抽象类,在驱动初始化时,会加载同一个程序集内的所有实现了IProtocolCommand接口的所有命令,并存储在 ...

  10. CSS水平垂直居中常见方法总结

    1.元素水平居中 当然最好使的是: margin: 0 auto; 居中不好使的原因: 1.元素没有设置宽度,没有宽度怎么居中嘛! 2.设置了宽度依然不好使,你设置的是行内元素吧,行内元素和块元素的区 ...