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. tomcat服务器启动执行的两个方法

    第一 SetApplicationContext(需要继承ApplicationContextAware)重写 第二 ContextInitialize(需要继承servleContet)重写,(co ...

  2. PHP 文件上传之如何识别文件伪装?——PHP的fileinfo扩展可!

    问题:文件上传时候需要验证上传的文件是否合法,文件伪装如何识别? 一个简单测试:把txt文件后缀直接改成jpg;上传 <!DOCTYPE html> <html> <ti ...

  3. iOS性能优化之内存(memory)优化

    https://www.jianshu.com/p/8662b2efbb23 近期在工作中,对APP进行了内存占用优化,减少了不少内存占用,在此将经验进行总结和分享,也欢迎大家进行交流. 在优化的过程 ...

  4. Mysql主从复制,双主热备

    Mysql主从复制: 主从复制: 主机准备工作: 开启bin.Log 注意:server-id  是唯一的值 重启mysql:service mysql restart 查看是否开启成功: 查看当前状 ...

  5. Apache和Nginx配置默认访问index.php

    Apache: .htaccess文件配置 Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d R ...

  6. iOS多线程编程的知识梳理

    多线程编程也称之为并发编程,由于其作用大,有比较多的理论知识,因此在面试中也是受到面试官的青睐.在日常项目开发中,至少网络请求上是需要使用到多线程知识的,虽然使用第三方的框架比如AFNetworkin ...

  7. ajax循环展示某段代码

    ajax内定义function,根据条件递归调用即可. success: function(data){ if (dataList[i].subModuleList){ sublist(dataLis ...

  8. 企业面试问题收集-java基础

    Java基础部分 1.1   在登录时进行后台验证,后台获取到loginpass与数据库值对比一直? 1.2   Java中的方法覆盖(Overwrite)和方法重载(Overloading)是什么意 ...

  9. WebRTC的音频编码(转)

    一.一个典型的IP通信模型 二.Server2Server技术分类 Server2Server这块也是一个专门的领域,这里只简单分个类. 1.同一国家相同运营商之间: 同一运营商之间也有丢包,在铁通, ...

  10. redhat7.6 配置主从DNS

    主DNS配置include指向的配置文件 /etc/named.rfc1912.zone 下面图片配置内容/etc/named.rfc1912.zones 从DNS配置 /etc/named.conf ...