Skip to content
Snippets Groups Projects
Commit b6f95f65 authored by akwizgran's avatar akwizgran
Browse files

Show all logcat ouput for the current process in TestingActivity.

parent 511b470a
No related branches found
No related tags found
No related merge requests found
...@@ -32,6 +32,7 @@ import java.util.Scanner; ...@@ -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 { ...@@ -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);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment