Jeff Sharkey

Software Engineer

Modifying the Android Logcat Stream for Full-Color Debugging

I’ve been keeping busy writing all sorts of fun stuff lately, but a few weeks ago I was really fighting with Android’s logcat debugging stream. It dumps out tons of useful information, but it’s easy to get lost in the flood of text.

So I whipped up a quick Python script that reformats the logcat output into a colorful stream that is much easier to visually follow.

One feature I really like is that it allocates unique colors for each “tag” used. This makes it really easy to visually separate dozens of tags into their source apps, and makes it easy to pick your app out in the crowd. This was inspired by the irssi nickcolor script, and the best way to explain is using an example:

There, isn’t that better? Just pipe your adb logcat output through the Python script to get started, or you can run the script directly to invoke adb:

$ adb logcat | ~/
$ ~/

To keep things simple, it assumes you’re using an ANSI-compatible terminal (most xterms are fine), and it uses a quick hack to detect your column width for wrapping.

It only took about 30 minutes to write up, but it’s already saved me more than that in lost debugging time. Feel free to use it yourself, and improve on it–here’s the source code released under an Apache 2.0 license.