Skip to content

Commit

Permalink
修复内部类崩溃问题,新增xml打印
Browse files Browse the repository at this point in the history
  • Loading branch information
pengwei1024 committed May 19, 2016
1 parent fc92ebf commit e03e64c
Show file tree
Hide file tree
Showing 10 changed files with 184 additions and 58 deletions.
9 changes: 8 additions & 1 deletion README.md
Expand Up @@ -61,6 +61,9 @@ double[][] doubles = {{1.2, 1.6, 1.7, 30, 33},
{1.2, 1.6, 1.7, 30, 33}};
LogUtils.d(doubles);

// 自定义tag
LogUtils.tag("我是自定义tag").d("我是打印内容");

// 其他用法
LogUtils.v("12345");
LogUtils.i("12345");
Expand Down Expand Up @@ -96,7 +99,7 @@ LogUtils.getLogConfig()

### Gradle
```groovy
compile 'com.apkfuns.logutils:library:1.3.1'
compile 'com.apkfuns.logutils:library:1.4.0'
```

### Eclipse导入Jar
Expand Down Expand Up @@ -138,6 +141,10 @@ click [here](https://github.com/pengwei1024/LogUtils/tree/master/annex) to downl
- 支持对象包含复杂对象,逻辑重构
* **1.3.1 (2016/05/09)**
- 修复某些情况下出现死循环的情况
* **1.4.0 (2016/05/19)**
- 支持设置临时tag
- 支持xml打印
- 解决[issue 10](https://github.com/pengwei1024/LogUtils/issues/10)内部类问题

## 7. About
* Blog: [apkfuns.com](http://apkfuns.com?from=github)
Expand Down
Binary file added annex/logutil-1.4.0.jar
Binary file not shown.
Expand Up @@ -2,8 +2,11 @@

import android.app.Activity;
import android.bluetooth.BluetoothGattService;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import com.apkfuns.logutils.FakeBounty;
import com.apkfuns.logutils.demo.helper.Child;
import com.apkfuns.logutils.demo.helper.DataHelper;
import com.apkfuns.logutils.LogUtils;
Expand Down Expand Up @@ -33,21 +36,21 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// LogUtils.d("12345");
// LogUtils.d("12%s3%s45", "a", "b");
// LogUtils.d(new NullPointerException("12345"));
// LogUtils.d(DataHelper.getObject());
// LogUtils.d(null);
LogUtils.d("12345");
LogUtils.d("12%s3%s45", "a", "b");
LogUtils.d(new NullPointerException("12345"));
LogUtils.d(DataHelper.getObject());
LogUtils.d(null);

// LogUtils.json(DataHelper.getJson());
//
// // 打印List
LogUtils.json(DataHelper.getJson());
////
//// // 打印List
LogUtils.d(DataHelper.getStringList());
//
// // 支持数据集合
////
//// // 支持数据集合
LogUtils.d(DataHelper.getObjectList());

// // 支持map输出
//
//// // 支持map输出
LogUtils.d(DataHelper.getObjectMap());

// Bundle支持
Expand All @@ -74,24 +77,21 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void run() {
LogUtils.e("run on new Thread()");
LogUtils.tag("自定义tag888 (*^__^*)")
.d("我是自定义tag O(∩_∩)O哈哈~");
}
}).start();

// System.out.println(ToStringBuilder.reflectionToString(DataHelper.getMan(),
// ToStringStyle.MULTI_LINE_STYLE));
// System.out.println(ToStringBuilder.reflectionToString(DataHelper.getOldMan(),
// ToStringStyle.DEFAULT_STYLE));


// 大文本输出
// LogUtils.e(DataHelper.getBigString(this));
LogUtils.e(DataHelper.getBigString(this));

// Intent测试
// Intent it = new Intent(
// Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
// it.putExtra("aaaa", "12345");
// it.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
// LogUtils.d(it);
Intent it = new Intent(
Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
it.putExtra("aaaa", "12345");
it.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
LogUtils.d(it);

// OkHttpClient client = new OkHttpClient();
// Request request = new Request.Builder()
Expand All @@ -108,7 +108,6 @@ public void run() {
// }
// });


Person p = DataHelper.getObject();
WeakReference<Person> wp = new WeakReference<Person>(p);
LogUtils.e(wp);
Expand All @@ -122,16 +121,25 @@ public void run() {
l.add(wp);
LogUtils.e(l);

LogUtils.tag("自定义tag (*^__^*)")
.d("我是自定义tag O(∩_∩)O哈哈~");

Child<Man> child = new Child<>("张三");
child.setParent(DataHelper.getMan());
// LogUtils.d(child);

LogUtils.d(new MulObject(5));

LogUtils.tag("自定义tag2345 (*^__^*)")
.d("我是自定义tag O(∩_∩)O哈哈~");

LogUtils.d(DataHelper.getNode("左结点", "右结点"));

LogUtils.d("12345678910");


LogUtils.tag("lalal").xml(DataHelper.getXml());

LogUtils.e(new FakeBounty());
}
}
Expand Up @@ -175,4 +175,8 @@ public static Node getNode(String leftNode, String rightNode) {
return node;
}

public static String getXml(){
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Pensons><Penson id=\"1\"><name>name</name><sex>男</sex><age>30</age></Penson><Penson id=\"2\"><name>name</name><sex>女</sex><age>27</age></Penson></Pensons>";
}

}
4 changes: 2 additions & 2 deletions library/build.gradle
Expand Up @@ -6,8 +6,8 @@ android {
defaultConfig {
minSdkVersion 8
targetSdkVersion 21
versionCode 18
versionName "1.3.1"
versionCode 20
versionName "1.4.0"
}
buildTypes {
release {
Expand Down
24 changes: 24 additions & 0 deletions library/src/main/java/com/apkfuns/logutils/FakeBounty.java
@@ -0,0 +1,24 @@
package com.apkfuns.logutils;

import java.util.ArrayList;
import java.util.List;

/**
* Created by pengwei on 16/5/19.
*/
public class FakeBounty {
public List<A> mA = new ArrayList<>();

public class A {
protected int a = 5;
public A() {

}
}

public FakeBounty() {
for (int i = 0; i < 20; i++) {
mA.add(new A());
}
}
}
34 changes: 14 additions & 20 deletions library/src/main/java/com/apkfuns/logutils/LogUtils.java
@@ -1,32 +1,14 @@
package com.apkfuns.logutils;



/**
* Created by pengwei08 on 2015/7/16.
* 日志管理器
*/
public final class LogUtils {

private static Printer printer;
private static LogConfigImpl logConfig;

static {
printer = new Logger();
logConfig = LogConfigImpl.getInstance();
}

/**
* suggest use getLogConfig().configAllowLog() replace configAllowLog
*/
@Deprecated
public static boolean configAllowLog = logConfig.isEnable();

/**
* suggest use getLogConfig().configTagPrefix() replace configTagPrefix
*/
@Deprecated
public static String configTagPrefix = logConfig.getTagPrefix();
private static Logger printer = new Logger();
private static LogConfigImpl logConfig = LogConfigImpl.getInstance();

/**
* 选项配置
Expand All @@ -37,6 +19,10 @@ public static LogConfig getLogConfig() {
return logConfig;
}

public static Printer tag(String tag) {
return printer.setTag(tag);
}

/**
* verbose输出
*
Expand Down Expand Up @@ -130,4 +116,12 @@ public static void wtf(Object object) {
public static void json(String json) {
printer.json(json);
}

/**
* 输出xml
* @param xml
*/
public static void xml(String xml) {
printer.xml(xml);
}
}

0 comments on commit e03e64c

Please sign in to comment.