Skip to content

Commit ace742f

Browse files
committed
see 04/02 log
1 parent 0cab34c commit ace742f

File tree

1 file changed

+54
-4
lines changed

1 file changed

+54
-4
lines changed

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

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,31 @@ private static void print2Console(final int type,
344344
final String tag,
345345
final String[] head,
346346
final String msg) {
347-
printBorder(type, tag, true);
348-
printHead(type, tag, head);
349-
printMsg(type, tag, msg);
350-
printBorder(type, tag, false);
347+
StringBuilder sb = new StringBuilder();
348+
sb.append(" ").append(LINE_SEP);
349+
if (sLogBorderSwitch) {
350+
sb.append(TOP_BORDER).append(LINE_SEP);
351+
for (String aHead : head) {
352+
sb.append(LEFT_BORDER).append(aHead).append(LINE_SEP);
353+
}
354+
sb.append(MIDDLE_BORDER).append(LINE_SEP);
355+
for (String line : msg.split(LINE_SEP)) {
356+
sb.append(LEFT_BORDER).append(line).append(LINE_SEP);
357+
}
358+
sb.append(BOTTOM_BORDER);
359+
} else {
360+
for (String aHead : head) {
361+
sb.append(aHead).append(LINE_SEP);
362+
}
363+
sb.append(msg);
364+
}
365+
366+
printMsg1(type, tag, sb.toString());
367+
//
368+
// printBorder(type, tag, true);
369+
// printHead(type, tag, head);
370+
// printMsg(type, tag, msg);
371+
// printBorder(type, tag, false);
351372
}
352373

353374
private static void printBorder(final int type, final String tag, boolean isTop) {
@@ -382,6 +403,23 @@ private static void printMsg(final int type, final String tag, final String msg)
382403
}
383404
}
384405

406+
private static void printMsg1(final int type, final String tag, final String msg) {
407+
int len = msg.length();
408+
int countOfSub = len / MAX_LEN;
409+
if (countOfSub > 0) {
410+
int index = 0;
411+
for (int i = 0; i < countOfSub; i++) {
412+
Log.println(type, tag, msg.substring(index, index + MAX_LEN));
413+
index += MAX_LEN;
414+
}
415+
if (index != len) {
416+
Log.println(type, tag, msg.substring(index, len));
417+
}
418+
} else {
419+
Log.println(type, tag, msg);
420+
}
421+
}
422+
385423
private static void printSubMsg(final int type, final String tag, final String msg) {
386424
if (!sLogBorderSwitch) {
387425
Log.println(type, tag, msg);
@@ -394,6 +432,18 @@ private static void printSubMsg(final int type, final String tag, final String m
394432
}
395433
}
396434

435+
private static void printSubMsg1(final int type, final String tag, final String msg) {
436+
if (!sLogBorderSwitch) {
437+
438+
return;
439+
}
440+
StringBuilder sb = new StringBuilder();
441+
String[] lines = msg.split(LINE_SEP);
442+
for (String line : lines) {
443+
Log.println(type, tag, LEFT_BORDER + line);
444+
}
445+
}
446+
397447
private static void print2File(final int type, final String tag, final String msg) {
398448
Date now = new Date(System.currentTimeMillis());
399449
String format = FORMAT.format(now);

0 commit comments

Comments
 (0)