Wednesday, 2 November 2011

Android - Colored logcat

With the introduction of Android, the concept of Logcat was also introduced. Basically it is a set of logs  printed in the console, like the method println() of Java do, but a bit more sophisticated. Here you can find more information:

The main problem with them is, if we compared them with the LogCat perspective included in the SDK for eclipse, they don't have any color. While messages like warning or error have very colorful characters in eclipse and thus, easy to see, in the terminal every message seems like the same.

Searching in the Internet, I found several scripts to add new lines to the logcat command and then, make them more colorful.

Linux and Mac os
For all the unix systems, there is a script done by Jeff Sharkey which could be executed in the terminal. You can find it here:

You should download it and change the extension of the file by .py
After it, execute the command:
adb logcat | ./

Adrian Vintu, inspired by Jeff Sharkey, has created a translator to execute the code of Jeff Sharkey and show it in the windows console.

You can find it here:

The steps to execute it are:
1. Download the file
2. Unzip the file. It contains:
  • A python script done by Adrian Vintu
  • The original python script done by Jeff Sharkey
  • logcat.bat: a console executable file which do the translation
3. Copy it into the platform-tool folder of Android SDK. For example:
4. Running the program by write
in the console

Normally I code with my laptop, which only has 13" inch of screen. After using those scripts, the pid, tag and the colors uses at least 1/3 part of my screen, which make it not so useful. If you have larger screen, it could be fine. But for my case, I prefer to use some tricks like adding several symbols (------------) at the begging of the important messages, which could make me easily distinguish them.


  1. where do you execute the command ? terminal says commands not found on machos thxxx

    1. You should have it in your actual directory or have the directory of the file in the environment variable of the system.

      You might see how to add a directory in the PATH.

  2. On Windows this isn't outputting anything.
    I have done python console redirection on Windows before and I think it required a few tweaks unique to Windows.
    Is this code confirmed to work w/ Windows, or do you think it will need a few tweaks?

    1. Yes, you are right. The program does not output anything. In fact, this has been reported on the developer's page:

      The good news is he know it, the bad news is he switched to another tool and I think he won't fix it.

      Since I am really busy, I don't have time to fix it neither. Sorry about it.