有的时候想调个试,结果发现一大堆乱七八糟的Log,再然后找半天(一脸嫌弃)
于是乎,自己写了个小玩意儿
https://github.com/Linyuzai/Demo4XLog
/**
* 是否允许log
*
* @param l
*/
public static void setLoggable(boolean l);
/**
* 是否输出调用类和方法
*
* @param logClassAndMethod
*/
public static void setLogClassAndMethod(boolean logClassAndMethod);
/**
* 是否允许log.v
*
* @param v
*/
public static void setVerbose(boolean v);
**
* 是否允许log.d
*
* @param d
*/
public static void setDebug(boolean d);
/**
* 是否允许log.i
*
* @param i
*/
public static void setInfo(boolean i);
/**
* 是否允许log.w
*
* @param w
*/
public static void setWarn(boolean w);
/**
* 是否允许log.e
*
* @param e
*/
public static void setError(boolean e);
/**
* 设置过滤器
*
* @param filter
*/
public static void setLogFilter(LogFilter filter);
LogFilter logFilter = new LogFilter() {
@Override
public boolean filter(String tag, String msg) {
if (msg.contains("m") || tag.contains("i"))
return false;
return true;
}
};
/**
* 设置过滤类,只显示此类的log
*
* @param filterClass
*/
public static void filterClass(Class filterClass);
/**
* 重置,重置之后的初始效果和普通Log一样
*/
ublic static void reset();
然后出来的效果就是
public class MyClass {
void log() {
XLog.e("myclass", "myclass..........");
}
}
XLog.v("v", "msg");
XLog.d("d", "debug");
XLog.i("i", "info");
XLog.w("w", "msg");
XLog.e("e", "error");
new MyClass().log();
09-15 02:33:34.096 25650-25650/com.linyuzai.demo4xlog V/v: [com.linyuzai.demo4xlog.MainActivity<onClick>(86)]msg
09-15 02:33:34.096 25650-25650/com.linyuzai.demo4xlog D/d: [com.linyuzai.demo4xlog.MainActivity<onClick>(87)]debug
09-15 02:33:34.096 25650-25650/com.linyuzai.demo4xlog I/i: [com.linyuzai.demo4xlog.MainActivity<onClick>(88)]info
09-15 02:33:34.097 25650-25650/com.linyuzai.demo4xlog W/w: [com.linyuzai.demo4xlog.MainActivity<onClick>(89)]msg
09-15 02:33:34.097 25650-25650/com.linyuzai.demo4xlog E/e: [com.linyuzai.demo4xlog.MainActivity<onClick>(90)]error
09-15 02:33:34.097 25650-25650/com.linyuzai.demo4xlog E/myclass: [com.linyuzai.demo4xlog.MyClass<log>(10)]myclass..........
可以输出,类,方法,行数,暂时没发现什么问题