转载请注明出处:王亟亟的大牛之路
Git上看到一个相当给力的工具框架LogUtils,可以让Log打印出json,list,Obj等等,进一步方便了我们的开发过程
包目录:
How to use?
Gradle: compile 'com.apkfuns.logutils:library:1.0.6'
Maven: <dependency>
<groupId>com.apkfuns.logutils</groupId>
<artifactId>library</artifactId>
<version>1.0.6</version>
</dependency>
Jar包下载地址:点击下载
效果:
// 输出字符串
LogUtils.d("12345");
// 输出参数
LogUtils.d("12%s3%d45", "a", 0);
// 输出异常
LogUtils.e(new NullPointerException("12345"));
// 输出对象
Person person = new Person();
person.setAge(11);
person.setId(001);
person.setName("Wjj");
LogUtils.d(person);
// 对象为空
LogUtils.d(null);
// 输出json(json默认debug打印)
String json = "{'a':'b','c':{'aa':234,'dd':{'az':12}}}";
LogUtils.json(json);
// 打印数据集合
List<Person> list1 = new ArrayList<>();
for(int i = 0; i < 4; i++){
list1.add(person);
}
LogUtils.d(list1);
// 打印数组
double[][] doubles = {{1.2, 1.6, 1.7, 30, 33},
{1.2, 1.6, 1.7, 30, 33},
{1.2, 1.6, 1.7, 30, 33},
{1.2, 1.6, 1.7, 30, 33}};
LogUtils.i(doubles);
测试用的Person
public class Person {
private int id;
private int age;
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
源码地址:http://yunpan.cn/cm8kH8k56qaPQ 访问密码 81e3