Re: [android-developers] Control level of Log class
No, it doesn't seem odd to me.
Logging is a debugging / diagnostic tool.
For every more or less complex project I've done, I've had to build my own debugging / diagnostic tools, because the general purpose tools didn't provide what was needed at some point.
Maybe it's because I'm a lousy programmer and can't always find and fix bugs in my code just by looking at it.
Or maybe it's because these days even the simple applications are quite complex, and it's especially true for mobile development.
FWIW, here is what I did.
I have a class, MyLog with static methods for logging stuff. The main one takes an integer "feature". There is a bunch of features (networking, database, etc.) defined as constants (MyLog.FEAT_NET, MyLog.FEAT_DATA, etc.) The class is configured using shared preferences, there is a global on/off setting as well as a bit mask for controlling specific featues.
The main logging method also takes a variable length list as its parameter, so I can do:
MyLog.msg(MyLog.FEAT_DATA, "Updated record _id = %d, uid = %d, with flag = %d", _id, uid, flag);
The method first checks if it should produce any output, and only then uses String.format() to create and output the string.
It also outputs the current thread id, and uses reflection to print the feature label:
<timestamp><appname>[DATA.10] Updated record _id = 10, uid = abcdef, with flag = 65536
-- Kostya
2011/6/4 Brill Pappin <bpappin@sixgreen.com>
It doesn't strike you as odd that the perfectly good logging class in Android requires you to invent your own implementation?--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home