提交 32012cd4 编写于 作者: B Blankj

see 11/06 log

上级 359f3764
......@@ -41,7 +41,7 @@
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.9.6-brightgreen.svg
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.9.7-brightgreen.svg
[auc]: https://github.com/Blankj/AndroidUtilCode
[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg
......
......@@ -41,7 +41,7 @@ If this ptoject helps you a lot, and you would like to support this ptoject's fu
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.9.6-brightgreen.svg
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.9.7-brightgreen.svg
[auc]: https://github.com/Blankj/AndroidUtilCode
[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg
......
......@@ -70,7 +70,7 @@ dependencies {
releaseImplementation leakCanary
testImplementation leakCanary
// compile 'com.blankj:utilcode:1.9.3'
// compile 'com.blankj:utilcode:1.9.7'
}
......@@ -56,7 +56,7 @@ public class LogActivity extends BaseBackActivity {
LogUtils.d("debug");
LogUtils.i("info");
LogUtils.w("warn");
LogUtils.e("初始化成功");
LogUtils.e("error");
LogUtils.a("assert");
}
};
......
......@@ -30,8 +30,8 @@ ext {
minSdkVersion = 14
targetSdkVersion = 22
versionCode = 100900600
versionName = '1.9.6'
versionCode = 100900700
versionName = '1.9.7'
// App dependencies
supportVersion = '26.1.0'
......
* 17/11/06 修复LogUtils多参数打印失败的问题
* 17/11/01 完善ShellUtil的Msg换行,感谢香脆的大鸡排
* 17/10/30 升级README
* 17/10/29 修复6.0内部存储安装失败问题
......
......@@ -2,7 +2,7 @@
Gradle:
``` groovy
compile 'com.blankj:utilcode:1.9.6'
compile 'com.blankj:utilcode:1.9.7'
```
......
......@@ -2,7 +2,7 @@
Gradle:
``` groovy
compile 'com.blankj:utilcode:1.9.6'
compile 'com.blankj:utilcode:1.9.7'
```
......
......@@ -83,7 +83,6 @@ public final class LogUtils {
private static final String BOTTOM_BORDER = "╚═══════════════════════════════════════════════════════════════════════════════════════════════════";
private static final int MAX_LEN = 4000;
private static final Format FORMAT = new SimpleDateFormat("MM-dd HH:mm:ss.SSS ", Locale.getDefault());
private static final String NULL_TIPS = "Log with null object.";
private static final String NULL = "null";
private static final String ARGS = "args";
private static final Config CONFIG = new Config();
......@@ -96,100 +95,100 @@ public final class LogUtils {
return CONFIG;
}
public static void v(final Object contents) {
log(V, sGlobalTag, contents);
public static void v(final Object content) {
log(V, sGlobalTag, content);
}
public static void v(final String tag, final Object content, final Object... contents) {
log(V, tag, content, contents);
}
public static void d(final Object contents) {
log(D, sGlobalTag, contents);
public static void d(final Object content) {
log(D, sGlobalTag, content);
}
public static void d(final String tag, final Object content, final Object... contents) {
log(D, tag, content, contents);
}
public static void i(final Object contents) {
log(I, sGlobalTag, contents);
public static void i(final Object content) {
log(I, sGlobalTag, content);
}
public static void i(final String tag, final Object content, final Object... contents) {
log(I, tag, content, contents);
}
public static void w(final Object contents) {
log(W, sGlobalTag, contents);
public static void w(final Object content) {
log(W, sGlobalTag, content);
}
public static void w(final String tag, final Object content, final Object... contents) {
log(W, tag, content, contents);
}
public static void e(final Object contents) {
log(E, sGlobalTag, contents);
public static void e(final Object content) {
log(E, sGlobalTag, content);
}
public static void e(final String tag, final Object content, final Object... contents) {
log(E, tag, content, contents);
}
public static void a(final Object contents) {
log(A, sGlobalTag, contents);
public static void a(final Object content) {
log(A, sGlobalTag, content);
}
public static void a(final String tag, final Object content, final Object... contents) {
log(A, tag, content, contents);
}
public static void file(final Object contents) {
log(FILE | D, sGlobalTag, contents);
public static void file(final Object content) {
log(FILE | D, sGlobalTag, content);
}
public static void file(@TYPE final int type, final Object contents) {
log(FILE | type, sGlobalTag, contents);
public static void file(@TYPE final int type, final Object content) {
log(FILE | type, sGlobalTag, content);
}
public static void file(final String tag, final Object contents) {
log(FILE | D, tag, contents);
public static void file(final String tag, final Object content) {
log(FILE | D, tag, content);
}
public static void file(@TYPE final int type, final String tag, final Object contents) {
log(FILE | type, tag, contents);
public static void file(@TYPE final int type, final String tag, final Object content) {
log(FILE | type, tag, content);
}
public static void json(final String contents) {
log(JSON | D, sGlobalTag, contents);
public static void json(final String content) {
log(JSON | D, sGlobalTag, content);
}
public static void json(@TYPE final int type, final String contents) {
log(JSON | type, sGlobalTag, contents);
public static void json(@TYPE final int type, final String content) {
log(JSON | type, sGlobalTag, content);
}
public static void json(final String tag, final String contents) {
log(JSON | D, tag, contents);
public static void json(final String tag, final String content) {
log(JSON | D, tag, content);
}
public static void json(@TYPE final int type, final String tag, final String contents) {
log(JSON | type, tag, contents);
public static void json(@TYPE final int type, final String tag, final String content) {
log(JSON | type, tag, content);
}
public static void xml(final String contents) {
log(XML | D, sGlobalTag, contents);
public static void xml(final String content) {
log(XML | D, sGlobalTag, content);
}
public static void xml(@TYPE final int type, final String contents) {
log(XML | type, sGlobalTag, contents);
public static void xml(@TYPE final int type, final String content) {
log(XML | type, sGlobalTag, content);
}
public static void xml(final String tag, final String contents) {
log(XML | D, tag, contents);
public static void xml(final String tag, final String content) {
log(XML | D, tag, content);
}
public static void xml(@TYPE final int type, final String tag, final String contents) {
log(XML | type, tag, contents);
public static void xml(@TYPE final int type, final String tag, final String content) {
log(XML | type, tag, content);
}
private static void log(final int type, final String tag, final Object... contents) {
......@@ -265,30 +264,26 @@ public final class LogUtils {
}
private static String processBody(final int type, final Object... contents) {
String body = NULL_TIPS;
if (contents != null) {
if (contents.length == 1) {
Object object = contents[0];
body = object == null ? NULL : object.toString();
if (type == JSON) {
body = formatJson(body);
} else if (type == XML) {
body = formatXml(body);
}
String body;
if (contents.length == 1) {
body = contents[0] == null ? NULL : contents[0].toString();
if (type == JSON) {
body = formatJson(body);
} else if (type == XML) {
body = formatXml(body);
}
} else {
StringBuilder sb = new StringBuilder();
int i = 0;
sb.append(generateArgLine(i++, contents[0] == null ? NULL : contents[0].toString()));
if (contents[1] == null) {
sb.append(generateArgLine(i, NULL));
} else {
StringBuilder sb = new StringBuilder();
for (int i = 0, len = contents.length; i < len; ++i) {
Object content = contents[i];
sb.append(ARGS)
.append("[")
.append(i)
.append("]")
.append(" = ")
.append(content == null ? NULL : content.toString())
.append(LINE_SEP);
for (Object content : (Object[]) contents[1]) {
sb.append(generateArgLine(i++, content == null ? NULL : content.toString()));
}
body = sb.toString();
}
body = sb.toString();
}
return body;
}
......@@ -321,7 +316,11 @@ public final class LogUtils {
return xml;
}
private static void print2Console(final int type, final String tag, final String[] head, String msg) {
private static String generateArgLine(int index, String content) {
return ARGS + "[" + index + "]" + " = " + content + LINE_SEP;
}
private static void print2Console(final int type, final String tag, final String[] head, final String msg) {
printBorder(type, tag, true);
printHead(type, tag, head);
printMsg(type, tag, msg);
......
......@@ -123,5 +123,4 @@ public class TestUtils {
public void test() throws Exception {
}
}
\ No newline at end of file
......@@ -122,10 +122,10 @@ public class TimeUtilsTest {
@Test
public void getFitTimeSpanByNow() throws Exception {
long spanMillis = 6 * TimeConstants.DAY + 6 * TimeConstants.HOUR + 6 * TimeConstants.MIN + 6 * TimeConstants.SEC;
assertEquals("6天6小时6分钟6秒", TimeUtils.getFitTimeSpanByNow(TimeUtils.millis2String(System.currentTimeMillis() + spanMillis), 5));
assertEquals("6天6小时6分钟6秒", TimeUtils.getFitTimeSpanByNow(TimeUtils.millis2String(System.currentTimeMillis() + spanMillis, mFormat), mFormat, 5));
assertEquals("6天6小时6分钟6秒", TimeUtils.getFitTimeSpanByNow(TimeUtils.millis2Date(System.currentTimeMillis() + spanMillis), 5));
assertEquals("6天6小时6分钟6秒", TimeUtils.getFitTimeSpanByNow(System.currentTimeMillis() + spanMillis, 5));
assertEquals("6天6小时6分钟6秒", TimeUtils.getFitTimeSpanByNow(TimeUtils.millis2String(System.currentTimeMillis() + spanMillis), 4));
assertEquals("6天6小时6分钟6秒", TimeUtils.getFitTimeSpanByNow(TimeUtils.millis2String(System.currentTimeMillis() + spanMillis, mFormat), mFormat, 4));
assertEquals("6天6小时6分钟6秒", TimeUtils.getFitTimeSpanByNow(TimeUtils.millis2Date(System.currentTimeMillis() + spanMillis), 4));
assertEquals("6天6小时6分钟6秒", TimeUtils.getFitTimeSpanByNow(System.currentTimeMillis() + spanMillis, 4));
}
@Test
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册