Tuesday, July 13, 2010

Log your applications

Looking at Log class you can see the isLoggable method.
With that you can check if the 'TAG' used in Log is loggable, so you can write something like that:
if (Log.isLoggable(MyTag, DEBUG)) {
Log.d(MyTag, "Debug line");
}

in this way you can call the Log.d() ONLY if MyTag can be debugged saving time of execution.

To 'mark' MyTag as loggable in DEBUG (default is INFO) just call in terminal:
adb shell setprop local.tag.MyTag DEBUG


Happy debug! ;)

No comments:

Post a Comment