164 lines
5.2 KiB
Java
164 lines
5.2 KiB
Java
package com.orhanobut.logger;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class PrettyFormatStrategy implements FormatStrategy {
|
|
private final int a;
|
|
private final int b;
|
|
private final boolean c;
|
|
private final LogStrategy d;
|
|
private final String e;
|
|
|
|
public static class Builder {
|
|
int a;
|
|
int b;
|
|
boolean c;
|
|
LogStrategy d;
|
|
String e;
|
|
|
|
public Builder a(int i) {
|
|
this.a = i;
|
|
return this;
|
|
}
|
|
|
|
public Builder b(int i) {
|
|
this.b = i;
|
|
return this;
|
|
}
|
|
|
|
private Builder() {
|
|
this.a = 2;
|
|
this.b = 0;
|
|
this.c = true;
|
|
this.e = "PRETTY_LOGGER";
|
|
}
|
|
|
|
public Builder a(boolean z) {
|
|
this.c = z;
|
|
return this;
|
|
}
|
|
|
|
public Builder a(LogStrategy logStrategy) {
|
|
this.d = logStrategy;
|
|
return this;
|
|
}
|
|
|
|
public Builder a(String str) {
|
|
this.e = str;
|
|
return this;
|
|
}
|
|
|
|
public PrettyFormatStrategy a() {
|
|
if (this.d == null) {
|
|
this.d = new LogcatLogStrategy();
|
|
}
|
|
return new PrettyFormatStrategy(this);
|
|
}
|
|
}
|
|
|
|
public static Builder a() {
|
|
return new Builder();
|
|
}
|
|
|
|
private void b(int i, String str) {
|
|
b(i, str, "├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄");
|
|
}
|
|
|
|
private void c(int i, String str) {
|
|
b(i, str, "┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────");
|
|
}
|
|
|
|
private PrettyFormatStrategy(Builder builder) {
|
|
Utils.a(builder);
|
|
this.a = builder.a;
|
|
this.b = builder.b;
|
|
this.c = builder.c;
|
|
this.d = builder.d;
|
|
this.e = builder.e;
|
|
}
|
|
|
|
private void b(int i, String str, String str2) {
|
|
Utils.a(str2);
|
|
this.d.a(i, str, str2);
|
|
}
|
|
|
|
private void c(int i, String str, String str2) {
|
|
Utils.a(str2);
|
|
for (String str3 : str2.split(System.getProperty("line.separator"))) {
|
|
b(i, str, "│ " + str3);
|
|
}
|
|
}
|
|
|
|
@Override // com.orhanobut.logger.FormatStrategy
|
|
public void a(int i, String str, String str2) {
|
|
Utils.a(str2);
|
|
String a = a(str);
|
|
c(i, a);
|
|
a(i, a, this.a);
|
|
byte[] bytes = str2.getBytes();
|
|
int length = bytes.length;
|
|
if (length <= 4000) {
|
|
if (this.a > 0) {
|
|
b(i, a);
|
|
}
|
|
c(i, a, str2);
|
|
a(i, a);
|
|
return;
|
|
}
|
|
if (this.a > 0) {
|
|
b(i, a);
|
|
}
|
|
for (int i2 = 0; i2 < length; i2 += 4000) {
|
|
c(i, a, new String(bytes, i2, Math.min(length - i2, 4000)));
|
|
}
|
|
a(i, a);
|
|
}
|
|
|
|
private String b(String str) {
|
|
Utils.a(str);
|
|
return str.substring(str.lastIndexOf(".") + 1);
|
|
}
|
|
|
|
private void a(int i, String str, int i2) {
|
|
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
|
|
if (this.c) {
|
|
b(i, str, "│ Thread: " + Thread.currentThread().getName());
|
|
b(i, str);
|
|
}
|
|
int a = a(stackTrace) + this.b;
|
|
if (i2 + a > stackTrace.length) {
|
|
i2 = (stackTrace.length - a) - 1;
|
|
}
|
|
String str2 = "";
|
|
while (i2 > 0) {
|
|
int i3 = i2 + a;
|
|
if (i3 < stackTrace.length) {
|
|
str2 = str2 + " ";
|
|
b(i, str, "│ " + str2 + b(stackTrace[i3].getClassName()) + "." + stackTrace[i3].getMethodName() + " (" + stackTrace[i3].getFileName() + ":" + stackTrace[i3].getLineNumber() + ")");
|
|
}
|
|
i2--;
|
|
}
|
|
}
|
|
|
|
private void a(int i, String str) {
|
|
b(i, str, "└────────────────────────────────────────────────────────────────────────────────────────────────────────────────");
|
|
}
|
|
|
|
private int a(StackTraceElement[] stackTraceElementArr) {
|
|
Utils.a(stackTraceElementArr);
|
|
for (int i = 5; i < stackTraceElementArr.length; i++) {
|
|
String className = stackTraceElementArr[i].getClassName();
|
|
if (!className.equals(LoggerPrinter.class.getName()) && !className.equals(Logger.class.getName())) {
|
|
return i - 1;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
private String a(String str) {
|
|
if (!Utils.a((CharSequence) str) && !Utils.a(this.e, str)) {
|
|
return this.e + "-" + str;
|
|
}
|
|
return this.e;
|
|
}
|
|
}
|