android Log工具框架,LogUtils讓你擺脫TAG的魔爪
阿新 • • 發佈:2019-02-04
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;
}
}