Rss feed of the tag

A developer tool : taming the logcat with pidcat

Written by Xavier Gouchet - 11 september 2013 - no comments

LogCat is a great logging feature which is part of the core Android Developper Experience™. Most of us using an IDE use the DDMS tool to view the LogCat outputs. Some might also use directly the console with adb logcat -v long, with maybe some grep or awk to enhance the result.

Well Jake Wharton (you know, the guy behind ActionBarSherlock) developped PidCat, a Python script to print the LogCat output in the console in a usefull way. Here's how it looks like.

PidCat Screenshot

After a couple of day, I find it better than DDMS LogCat view. And what's great is that it's Open Source, so I'll probably add some features in it myself. You can download it or fork it from PidCat Github Repository.

Taming the LogCat

Written by Xavier Gouchet - 30 january 2013 - no comments

A couple of days ago, a question popped on StackOverflow, asking how to link a log line in LogCat to the source code, just like it happens when you Log an exception.

The first answers where to add a fake Exception. Naturally, there will be the line you want, but also a lot of noise in your LogCat.

Then someone proposed a method to simulated an exception Log, without the whole stacktrace (see the answer here).

The solution works fine, but can be quite verbose. With a little bit of try and error, I found out that the most important part is the "at (file.java:42)". It doesn't matter where it is in the message. You can even have mor than one, it only takes into account the last one.

So I worked out a LogLink class to use this systme anywhere and seamlessly. Here's an example of how it works :

	// default value is INSERT_LAST, and you can call it only once
	// also exist as v, d, w, e and wtf 
	LogUtils.i("MyClass", "A message");

The previous code will output the following output

MyClass     A message at (MyClass.java:42)

You can see and download the LogUtils class here