We have all seen this:


Log.d(tag, myClass.getSimpleName() + ":" + msg, tr);
Log.d(tag, obj.getClass().getSimpleName() + ":" + msg);

With it always on the programmer to write the extra log details per class they want to log. what if we did not have to? What if in a class we have this instead:


setMyLogTag(Ourclass.class);

//in our method we want to log
OurLogger.i();
// or
OurLogger.i(“tag” “message”);

and we get something like this:


08-01 10:38:56.446: INFO/MyTAG(100): [MyPackage.Name][MyClassName][Method][122]
08-01 10:38;57.447: INFO/MyTag(100): [MyPackage.Name][MyClassName][Method][12]

You will notice that I will be getting a stack trace back with all my packages, classes, and methods labeled and even line numbers. Now some things,this is only for those who use instrumented testing. How did I do it? The article at my gh-pages is coming, you should probably bookmark that site.. Fro those that cannot wait, obviously I am using Stack Trace.

But, I am using some new tricks that are somewhat non obvious. But the main thing I have reduced my coding log statements to something extremely simple that is configurable to give me enough details when I want it with no increase in coding log statements to get that detail, ie I hacked the Logging. Neat huh?