Reputation: 3104
I want to create an arraylist of logcat data as follows: time level tag text ..... Example :
06-13 13:34:43:434 W myApp blehblehbleh
How do I filter the logcat to obtain this result? More precisely, what goes into the .exec(" ") part to get these values because "logcat -d" seems to get everything.
log = new ArrayList<String>();
try {
process = Runtime.getRuntime().exec("logcat -d");
} catch (IOException e1) {
e1.printStackTrace();
}
bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
try {
while ((line = bufferedReader.readLine()) != null){
log.add(line);
}
Upvotes: 0
Views: 1275
Reputation: 7027
This will print all the logs from YOUR_TAG_HERE and it will filter out the rest:
logcat -d YOUR_TAG_HERE:V *:S
Upvotes: 2
Reputation: 4967
You could simple to do a
if (line.contains("myApp")) log.add(line);
in your loop to only add lines from your app. In your current setup that seems like the quickest way.
Upvotes: 0