Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get logcat buffer from phone app
private String getLogData(String level) {
Log.d(TAG, "Getting log data for level: "+level);
StringBuilder log = new StringBuilder();
try {
Process process = Runtime.getRuntime().exec("logcat -d");
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
String line = "";
while ((line = bufferedReader.readLine()) != null) {
log.append(line+"\n");
}
} catch (IOException e) {
e.printStackTrace();
}
return log.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment