When you’re building Android ROMs, sometimes the system fails to boot or does other wonky things and leaves you to debug what is going on. When that happens, you turn to the ever so trusty adb logcat. But wait - the system is on a loop and is spewing logcats all over the place. What do you do?

Simple. You only look at the lines with the tag “E” in it. “E” for “Error”. Simple.

Until you realize, it’s like looking for needles in a haystack. There’s too many freaking logcat lines!

That’s why I wrote a parser to get rid of the useless lines.

Make a file called parse.py and copy the following contents into the file:

OK, cool, so how do you use it? Simple. Just pipe logcat output like so:

adb logcat > crash.logcat

Then run the file like this:

python3 parse.py

The neatly formatted file should be at output.logcat. Take a look and see what the bug is. Hope this helped!

Help, I ran the script and the output is blank!

Make sure the file name is correct.

In some instances, the ADB logcat may be in a different format. If that is the case, you will have to modify the position selection. In the script, find the line:

    if log[4] == "E":

Change the number 4 until you get the correct output.

What about the easier way of grep-ing for ----- beginning of crash?

I’ve found that method works in a cinch, but it doesn’t give you a good overview of what’s going on with your ROM. Often something non-crucial crashes during the booting sequence and leaves you to wonder why the system is boot-looping on something that it shouldn’t be boot-looping on. This script solves that problem by showing you all error lines obscured by the noise.