103 lines
4.1 KiB
Java
103 lines
4.1 KiB
Java
package com.discord.utilities.systemlog;
|
|
|
|
import com.discord.utilities.collections.FixedSizeLineBuffer;
|
|
import d0.g0.c;
|
|
import d0.g0.w;
|
|
import d0.v.a;
|
|
import d0.z.d.m;
|
|
import java.io.BufferedReader;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.InputStreamReader;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
/* compiled from: SystemLogCapture.kt */
|
|
public final class SystemLogCapture {
|
|
public static final Companion Companion = new Companion(null);
|
|
private final FixedSizeLineBuffer buffer = new FixedSizeLineBuffer(524288);
|
|
private final FixedSizeLineBuffer tombstoneBuffer = new FixedSizeLineBuffer(102400);
|
|
|
|
/* compiled from: SystemLogCapture.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final boolean shouldIncludeLogLine$app_productionBetaRelease(String str) {
|
|
m.checkNotNullParameter(str, "line");
|
|
return !w.contains$default((CharSequence) str, (CharSequence) "chatty : uid=", false, 2, (Object) null);
|
|
}
|
|
}
|
|
|
|
public static final /* synthetic */ void access$start(SystemLogCapture systemLogCapture) {
|
|
systemLogCapture.start();
|
|
}
|
|
|
|
private final void start() {
|
|
if (!new File("/system/bin/logcat").exists()) {
|
|
this.buffer.addLine("Unable to locate '/system/bin/logcat'");
|
|
return;
|
|
}
|
|
while (true) {
|
|
Process process = null;
|
|
try {
|
|
process = new ProcessBuilder("/system/bin/logcat").redirectErrorStream(true).start();
|
|
m.checkNotNullExpressionValue(process, "logcatProcess");
|
|
InputStream inputStream = process.getInputStream();
|
|
m.checkNotNullExpressionValue(inputStream, "logcatProcess.inputStream");
|
|
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, c.a);
|
|
BufferedReader bufferedReader = inputStreamReader instanceof BufferedReader ? (BufferedReader) inputStreamReader : new BufferedReader(inputStreamReader, 8192);
|
|
while (true) {
|
|
try {
|
|
String readLine = bufferedReader.readLine();
|
|
if (readLine == null) {
|
|
break;
|
|
}
|
|
if (Companion.shouldIncludeLogLine$app_productionBetaRelease(readLine)) {
|
|
this.buffer.addLine(readLine);
|
|
}
|
|
if (SystemLogUtils.INSTANCE.getRegexExtractTombstone$app_productionBetaRelease().matches(readLine)) {
|
|
this.tombstoneBuffer.addLine(readLine);
|
|
}
|
|
} catch (IOException unused) {
|
|
}
|
|
}
|
|
bufferedReader.close();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
this.buffer.addLine("Exception getting system logs '" + e + '\'');
|
|
StackTraceElement[] stackTrace = e.getStackTrace();
|
|
m.checkNotNullExpressionValue(stackTrace, "e.stackTrace");
|
|
for (StackTraceElement stackTraceElement : stackTrace) {
|
|
this.buffer.addLine(" " + stackTraceElement);
|
|
}
|
|
if (0 == 0) {
|
|
}
|
|
} catch (Throwable th) {
|
|
if (0 != 0) {
|
|
process.destroy();
|
|
}
|
|
throw th;
|
|
}
|
|
process.destroy();
|
|
Thread.sleep(1000);
|
|
}
|
|
}
|
|
|
|
public final void appendOutput(StringBuilder sb) {
|
|
m.checkNotNullParameter(sb, "sb");
|
|
this.tombstoneBuffer.appendString(sb);
|
|
this.buffer.appendString(sb);
|
|
}
|
|
|
|
public final String getOutput() {
|
|
return this.tombstoneBuffer.getString() + '\n' + this.buffer.getString();
|
|
}
|
|
|
|
public final Thread startThread() {
|
|
return a.thread$default(true, true, null, SystemLogCapture.class.getSimpleName(), 0, new SystemLogCapture$startThread$1(this), 20, null);
|
|
}
|
|
}
|