File tree Expand file tree Collapse file tree 3 files changed +49
-3
lines changed
java/com/haoge/sample/easyandroid/activities
utils/src/main/java/com/haoge/easyandroid/easy Expand file tree Collapse file tree 3 files changed +49
-3
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,26 @@ class EasyLogActivity: BaseActivity() {
5757 EasyLog .DEFAULT .d(JSON .toJSONString(any))
5858 }
5959
60+ @OnClick(R .id.printSimplePOJO)
61+ fun printSimplePOJO () {
62+ EasyLog .DEFAULT .d(Simple (" Haoge" ))
63+ }
64+
65+ @OnClick(R .id.printComplexPOJO)
66+ fun printComplexPOJO () {
67+ EasyLog .DEFAULT .d(Complex (" complex message" , Simple (" kotlin" )))
68+ }
69+
70+ @OnClick(R .id.printCirclePOJO)
71+ fun printCirclePOJO () {
72+ val a = CircleA (null )
73+ val b = CircleB (null )
74+ a.b = b
75+ b.a = a
76+
77+ EasyLog .DEFAULT .e(a)
78+ }
79+
6080 @OnClick(R .id.printException)
6181 fun printException () {
6282 // 默认输出的列表最长长度为10,所以这里数量超出限制时。将会进行平铺展示。
@@ -100,4 +120,12 @@ object MyLog {
100120 fun e (message : Any? ) {
101121 log.e(message)
102122 }
103- }
123+ }
124+
125+ data class Simple (val name : String )
126+
127+ data class Complex (val message : String , val simple : Simple )
128+
129+ data class CircleA (var b : CircleB ? )
130+
131+ data class CircleB (var a : CircleA ? )
Original file line number Diff line number Diff line change 5050 android : layout_width =" match_parent"
5151 android : layout_height =" wrap_content" />
5252
53+ <Button
54+ android : id =" @+id/printSimplePOJO"
55+ android : text =" 打印简单对象"
56+ android : layout_width =" match_parent"
57+ android : layout_height =" wrap_content" />
58+
59+ <Button
60+ android : id =" @+id/printComplexPOJO"
61+ android : text =" 打印复杂对象"
62+ android : layout_width =" match_parent"
63+ android : layout_height =" wrap_content" />
64+
65+ <Button
66+ android : id =" @+id/printCirclePOJO"
67+ android : text =" 打印循环引用对象"
68+ android : layout_width =" match_parent"
69+ android : layout_height =" wrap_content" />
70+
5371 <Button
5472 android : id =" @+id/printException"
5573 android : text =" 打印异常堆栈"
Original file line number Diff line number Diff line change @@ -130,7 +130,7 @@ class EasyFormatter private constructor(private val builder: Builder) {
130130 return StringBuilder (any.toString())
131131 }
132132
133- val result = StringBuilder (" [${any.javaClass.simpleName} @ ${any.hashCode()} ]{" )
133+ val result = StringBuilder (" [${any.javaClass.simpleName} ]{" )
134134 val container = mutableMapOf<String , Any >()
135135 scanFields(any, any.javaClass, container)
136136
@@ -252,7 +252,7 @@ class EasyFormatter private constructor(private val builder: Builder) {
252252
253253 private fun checkIfFormatted (any : Any , invoke : ()-> StringBuilder ):StringBuilder {
254254 return if (list.contains(any)) {
255- StringBuilder (" (circle ref):${any.javaClass.simpleName} @ ${any.hashCode() }" )
255+ StringBuilder (" { (circle ref):${any.javaClass.simpleName} }" )
256256 } else {
257257 list.add(any)
258258 invoke.invoke()
You can’t perform that action at this time.
0 commit comments