Show all logcat ouput for the current process in TestingActivity.

This commit is contained in:
akwizgran
2014-03-03 18:52:25 +00:00
parent 511b470aa4
commit b6f95f6540

View File

@@ -32,6 +32,7 @@ import java.util.Scanner;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.regex.Pattern;
import javax.inject.Inject; import javax.inject.Inject;
@@ -290,18 +291,22 @@ public class TestingActivity extends BriarActivity implements OnClickListener {
StringBuilder log = new StringBuilder(); StringBuilder log = new StringBuilder();
try { try {
Runtime runtime = Runtime.getRuntime(); int pid = android.os.Process.myPid();
Process process = runtime.exec("logcat -d -s TorPlugin"); Pattern pattern = Pattern.compile("./[^(]+\\( *" + pid + "\\):.*");
Process process = Runtime.getRuntime().exec("logcat -d *:I");
Scanner scanner = new Scanner(process.getInputStream()); Scanner scanner = new Scanner(process.getInputStream());
while(scanner.hasNextLine()) { while(scanner.hasNextLine()) {
log.append(scanner.nextLine()); String line = scanner.nextLine();
log.append('\n'); if(pattern.matcher(line).matches()) {
log.append(line);
log.append('\n');
}
} }
scanner.close(); scanner.close();
} catch(IOException e) { } catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} }
statusMap.put("Tor log:", log.toString()); statusMap.put("Debugging log:", log.toString());
return Collections.unmodifiableMap(statusMap); return Collections.unmodifiableMap(statusMap);
} }