Skip to content

Commit 6bf3013

Browse files
committed
see 11/07 log
1 parent 32012cd commit 6bf3013

File tree

10 files changed

+96
-71
lines changed

10 files changed

+96
-71
lines changed

README-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
4343

44-
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.9.7-brightgreen.svg
44+
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.9.8-brightgreen.svg
4545
[auc]: https://github.com/Blankj/AndroidUtilCode
4646

4747
[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ If this ptoject helps you a lot, and you would like to support this ptoject's fu
4141

4242
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
4343

44-
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.9.7-brightgreen.svg
44+
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.9.8-brightgreen.svg
4545
[auc]: https://github.com/Blankj/AndroidUtilCode
4646

4747
[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ dependencies {
7070
releaseImplementation leakCanary
7171
testImplementation leakCanary
7272

73-
// compile 'com.blankj:utilcode:1.9.7'
73+
// compile 'com.blankj:utilcode:1.9.8'
7474
}
7575

7676

app/src/main/java/com/blankj/androidutilcode/core/log/LogActivity.java

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -158,32 +158,44 @@ public void onWidgetClick(View view) {
158158
LogUtils.a("assert");
159159
break;
160160
case R.id.btn_log_with_tag:
161-
LogUtils.v("customTag", "verbose");
162-
LogUtils.d("customTag", "debug");
163-
LogUtils.i("customTag", "info");
164-
LogUtils.w("customTag", "warn");
165-
LogUtils.e("customTag", "error");
166-
LogUtils.a("customTag", "assert");
161+
LogUtils.vTag("customTag", "verbose");
162+
LogUtils.dTag("customTag", "debug");
163+
LogUtils.iTag("customTag", "info");
164+
LogUtils.wTag("customTag", "warn");
165+
LogUtils.eTag("customTag", "error");
166+
LogUtils.aTag("customTag", "assert");
167167
break;
168168
case R.id.btn_log_in_new_thread:
169169
Thread thread = new Thread(mRunnable);
170170
thread.start();
171171
break;
172172
case R.id.btn_log_null:
173173
LogUtils.v(null);
174+
LogUtils.v(null, null);
174175
LogUtils.d(null);
176+
LogUtils.d(null, null);
175177
LogUtils.i(null);
178+
LogUtils.i(null, null);
176179
LogUtils.w(null);
180+
LogUtils.w(null, null);
177181
LogUtils.e(null);
182+
LogUtils.e(null, null);
178183
LogUtils.a(null);
184+
LogUtils.a(null, null);
179185
break;
180186
case R.id.btn_log_many_params:
181-
LogUtils.v("customTag", "verbose0", "verbose1");
182-
LogUtils.d("customTag", "debug0", "debug1");
183-
LogUtils.i("customTag", "info0", "info1");
184-
LogUtils.w("customTag", "warn0", "warn1");
185-
LogUtils.e("customTag", "error0", "error1");
186-
LogUtils.a("customTag", "assert0", "assert1");
187+
LogUtils.v("verbose0", "verbose1");
188+
LogUtils.vTag("customTag", "verbose0", "verbose1");
189+
LogUtils.d("debug0", "debug1");
190+
LogUtils.dTag("customTag", "debug0", "debug1");
191+
LogUtils.i("info0", "info1");
192+
LogUtils.iTag("customTag", "info0", "info1");
193+
LogUtils.w("warn0", "warn1");
194+
LogUtils.wTag("customTag", "warn0", "warn1");
195+
LogUtils.e("error0", "error1");
196+
LogUtils.eTag("customTag", "error0", "error1");
197+
LogUtils.a("assert0", "assert1");
198+
LogUtils.aTag("customTag", "assert0", "assert1");
187199
break;
188200
case R.id.btn_log_long:
189201
LogUtils.d(longStr);

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ ext {
3030
minSdkVersion = 14
3131
targetSdkVersion = 22
3232

33-
versionCode = 100900700
34-
versionName = '1.9.7'
33+
versionCode = 100900800
34+
versionName = '1.9.8'
3535

3636
// App dependencies
3737
supportVersion = '26.1.0'

update_log.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* 17/11/07 完善LogUtils无tag的多参数
12
* 17/11/06 修复LogUtils多参数打印失败的问题
23
* 17/11/01 完善ShellUtil的Msg换行,感谢香脆的大鸡排
34
* 17/10/30 升级README

utilcode/README-CN.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Gradle:
44
``` groovy
5-
compile 'com.blankj:utilcode:1.9.7'
5+
compile 'com.blankj:utilcode:1.9.8'
66
```
77

88

@@ -349,12 +349,18 @@ Config.setBorderSwitch : 设置log边框开关
349349
Config.setConsoleFilter : 设置log控制台过滤器
350350
Config.setFileFilter : 设置log文件过滤器
351351
Config.setStackDeep : 设置log栈深度
352-
v : Verbose日志
353-
d : Debug日志
354-
i : Info日志
355-
w : Warn日志
356-
e : Error日志
357-
a : Assert日志
352+
v : tag为类名的Verbose日志
353+
vTag : 自定义tag的Verbose日志
354+
d : tag为类名的Debug日志
355+
dTag : 自定义tag的Debug日志
356+
i : tag为类名的Info日志
357+
iTag : 自定义tag的Info日志
358+
w : tag为类名的Warn日志3
359+
wTag : 自定义tag的Warn日志
360+
e : tag为类名的Error日志
361+
eTag : 自定义tag的Error日志
362+
a : tag为类名的Assert日志
363+
aTag : 自定义tag的Assert日志
358364
file : log到文件
359365
json : log字符串之json
360366
xml : log字符串之xml

utilcode/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Gradle:
44
``` groovy
5-
compile 'com.blankj:utilcode:1.9.7'
5+
compile 'com.blankj:utilcode:1.9.8'
66
```
77

88

@@ -350,11 +350,17 @@ Config.setConsoleFilter
350350
Config.setFileFilter
351351
Config.setStackDeep
352352
v
353+
vTag
353354
d
355+
dTag
354356
i
357+
iTag
355358
w
359+
wTag
356360
e
361+
eTag
357362
a
363+
aTag
358364
file
359365
json
360366
xml

utilcode/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,5 @@ dependencies {
5858
testImplementation "org.robolectric:robolectric:$rootProject.ext.robolectricVersion"
5959
testImplementation "com.android.support:support-v4:$rootProject.ext.supportVersion"
6060
}
61-
//apply from: "../bintrayUpload.gradle"
61+
apply from: "../bintrayUpload.gradle"
6262
//gradle bintrayUpload

utilcode/src/main/java/com/blankj/utilcode/util/LogUtils.java

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -95,52 +95,52 @@ public static Config getConfig() {
9595
return CONFIG;
9696
}
9797

98-
public static void v(final Object content) {
99-
log(V, sGlobalTag, content);
98+
public static void v(final Object... contents) {
99+
log(V, sGlobalTag, contents);
100100
}
101101

102-
public static void v(final String tag, final Object content, final Object... contents) {
103-
log(V, tag, content, contents);
102+
public static void vTag(final String tag, final Object... contents) {
103+
log(V, tag, contents);
104104
}
105105

106-
public static void d(final Object content) {
107-
log(D, sGlobalTag, content);
106+
public static void d(final Object... contents) {
107+
log(D, sGlobalTag, contents);
108108
}
109109

110-
public static void d(final String tag, final Object content, final Object... contents) {
111-
log(D, tag, content, contents);
110+
public static void dTag(final String tag, final Object... contents) {
111+
log(D, tag, contents);
112112
}
113113

114-
public static void i(final Object content) {
115-
log(I, sGlobalTag, content);
114+
public static void i(final Object... contents) {
115+
log(I, sGlobalTag, contents);
116116
}
117117

118-
public static void i(final String tag, final Object content, final Object... contents) {
119-
log(I, tag, content, contents);
118+
public static void iTag(final String tag, final Object... contents) {
119+
log(I, tag, contents);
120120
}
121121

122-
public static void w(final Object content) {
123-
log(W, sGlobalTag, content);
122+
public static void w(final Object... contents) {
123+
log(W, sGlobalTag, contents);
124124
}
125125

126-
public static void w(final String tag, final Object content, final Object... contents) {
127-
log(W, tag, content, contents);
126+
public static void wTag(final String tag, final Object... contents) {
127+
log(W, tag, contents);
128128
}
129129

130-
public static void e(final Object content) {
131-
log(E, sGlobalTag, content);
130+
public static void e(final Object... contents) {
131+
log(E, sGlobalTag, contents);
132132
}
133133

134-
public static void e(final String tag, final Object content, final Object... contents) {
135-
log(E, tag, content, contents);
134+
public static void eTag(final String tag, final Object... contents) {
135+
log(E, tag, contents);
136136
}
137137

138-
public static void a(final Object content) {
139-
log(A, sGlobalTag, content);
138+
public static void a(final Object... contents) {
139+
log(A, sGlobalTag, contents);
140140
}
141141

142-
public static void a(final String tag, final Object content, final Object... contents) {
143-
log(A, tag, content, contents);
142+
public static void aTag(final String tag, final Object... contents) {
143+
log(A, tag, contents);
144144
}
145145

146146
public static void file(final Object content) {
@@ -264,26 +264,30 @@ private static TagHead processTagAndHead(String tag) {
264264
}
265265

266266
private static String processBody(final int type, final Object... contents) {
267-
String body;
268-
if (contents.length == 1) {
269-
body = contents[0] == null ? NULL : contents[0].toString();
270-
if (type == JSON) {
271-
body = formatJson(body);
272-
} else if (type == XML) {
273-
body = formatXml(body);
274-
}
275-
} else {
276-
StringBuilder sb = new StringBuilder();
277-
int i = 0;
278-
sb.append(generateArgLine(i++, contents[0] == null ? NULL : contents[0].toString()));
279-
if (contents[1] == null) {
280-
sb.append(generateArgLine(i, NULL));
267+
String body = NULL;
268+
if (contents != null) {
269+
if (contents.length == 1) {
270+
Object object = contents[0];
271+
if (object != null) body = object.toString();
272+
if (type == JSON) {
273+
body = formatJson(body);
274+
} else if (type == XML) {
275+
body = formatXml(body);
276+
}
281277
} else {
282-
for (Object content : (Object[]) contents[1]) {
283-
sb.append(generateArgLine(i++, content == null ? NULL : content.toString()));
278+
StringBuilder sb = new StringBuilder();
279+
for (int i = 0, len = contents.length; i < len; ++i) {
280+
Object content = contents[i];
281+
sb.append(ARGS)
282+
.append("[")
283+
.append(i)
284+
.append("]")
285+
.append(" = ")
286+
.append(content == null ? NULL : content.toString())
287+
.append(LINE_SEP);
284288
}
289+
body = sb.toString();
285290
}
286-
body = sb.toString();
287291
}
288292
return body;
289293
}
@@ -316,10 +320,6 @@ private static String formatXml(String xml) {
316320
return xml;
317321
}
318322

319-
private static String generateArgLine(int index, String content) {
320-
return ARGS + "[" + index + "]" + " = " + content + LINE_SEP;
321-
}
322-
323323
private static void print2Console(final int type, final String tag, final String[] head, final String msg) {
324324
printBorder(type, tag, true);
325325
printHead(type, tag, head);

0 commit comments

Comments
 (0)