Skip to content

Commit ce637a7

Browse files
committed
Fixed throwable doubles info
1 parent c46a676 commit ce637a7

File tree

8 files changed

+1617
-1459
lines changed

8 files changed

+1617
-1459
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ add to your dependencies in build.gradle
110110

111111
Changelog
112112
---------
113+
#### 1.4.10 -- Fixed throwable doubles info
114+
* Fixed throwable doubles info
115+
113116
#### 1.4.8 -- removed annotations
114117
* removed annotations for backward compatibility
115118

log/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
22

33
def versionMajor = 1
44
def versionMinor = 4
5-
def versionPatch = 9
5+
def versionPatch = 10
66

77
version = "${versionMajor}.${versionMinor}.${versionPatch}"
88

log/src/main/java/ua/at/tsvetkov/util/Format.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ final class Format {
8383
static final String NL = "\n";
8484
static final String ARRAY = "Array";
8585
public static final char SPACE = ' ';
86+
public static final String AT = "at ";
8687

8788
static volatile int maxTagLength = MAX_TAG_LENGTH;
8889
static volatile int beforeTagSpacesCount;
@@ -815,7 +816,9 @@ static StringBuilder getFormattedMessage(StringBuilder stringBuilder, String mes
815816
static StringBuilder getFormattedThrowable(String message, Throwable throwable) {
816817
String[] lines = null;
817818
if (message != null) {
818-
lines = message.split("\\n");
819+
lines = message.concat("\n" + getThrowableMessage(throwable)).split("\\n");
820+
} else {
821+
lines = getThrowableMessage(throwable).split("\\n");
819822
}
820823
int linesCount = getLinesCount(lines, throwable);
821824
lines = createLines(throwable, lines, linesCount);
@@ -833,6 +836,11 @@ static StringBuilder getFormattedThrowable(String message, Throwable throwable)
833836
return sb;
834837
}
835838

839+
@NonNull
840+
private static String getThrowableMessage(Throwable throwable) {
841+
return throwable.getClass().getName() + ": " + throwable.getMessage();
842+
}
843+
836844
private static int getLinesCount(String title, String[] lines) {
837845
int count = (lines == null) ? 0 : lines.length;
838846
if (Log.isLogOutlined) {
@@ -900,9 +908,9 @@ private static String[] createLines(Throwable throwable, String[] lines, int cou
900908
StackTraceElement[] stack = throwable.getStackTrace();
901909
for (int i = 0; i < stack.length; i++) {
902910
if (i == 0) {
903-
lns[linesCount + 1 + i] = THROWABLE_DELIMITER_START + stack[i].toString();
911+
lns[linesCount + 1 + i] = THROWABLE_DELIMITER_START + AT + stack[i].toString();
904912
} else {
905-
lns[linesCount + 1 + i] = THROWABLE_DELIMITER_START + THROWABLE_DELIMITER_PREFIX + stack[i].toString();
913+
lns[linesCount + 1 + i] = THROWABLE_DELIMITER_START + THROWABLE_DELIMITER_PREFIX + AT + stack[i].toString();
906914
}
907915
}
908916
}
@@ -965,7 +973,8 @@ static void addStackTrace(StringBuilder sb, Thread thread) {
965973
static void addStackTrace(StringBuilder sb, StackTraceElement[] traces) {
966974
for (int i = 4; i < traces.length; i++) {
967975
sb.append(THROWABLE_DELIMITER_PREFIX);
968-
sb.append(traces[i].toString());
976+
sb.append(AT);
977+
sb.append( traces[i].toString());
969978
sb.append('\n');
970979
}
971980
}

0 commit comments

Comments
 (0)