Today, I found out about android.util.log. This class gives you a better way to print out logging statements. So, instead of doing,
System.out.println("Look! Code finished, the value is:"+value);
which would print data to the LogCat window in Eclipse with a logging level of INFO, you can do something like,
Log.w("MyTag","Look! Code finished, the value is:"+value);
which prints data to the same LogCat window in Eclipse with a logging level of WARN with a tag of "MyTag". You can adjust the logging level by using Log.v, Log.d, Log.i, Log,e, Log.a which are verbose, debug, info, error, and assert respectively.
The best part of this logging is the tag. With the tag, in Eclipse you can create a filter in the LogCat window, and just see your tagged logging messages. This is very nice if you are testing on a real phone or tablet which may have a lot of other logging messages unrelated to the app you are testing.
This is much better than just using a System.out.println, because the system messages are sometimes very hard to find among the clutter of other logging output.
I think small changes like this reduces developer frustration and friction, which ultimately leads to improvements in developer productivity.
No comments:
Post a Comment