I assume most of you are aware of android.util.Log All logging methods accept \'String tag\' as a first argument.
And my question is How do you usually tag y
I have created a class of Static variables, methods and classes named as S.
The following is the logging method:
public static void L(Context ctx, Object s) {
Log.d("CCC " + ctx.getClass().getName().replace(ctx.getPackageName(), ""), s.toString());
}
It is called in any class as S.L(this, whaterver_object); The getClass().getName() also appends the package name, hence, I am removing it out to avoid making the tag unnecessarily long.
Advantages:
Log.d(TAG,toStringLog.d ever as I just have to delete the method and the locations of all logs get marked red.CCC (a short, easy to type string) so that it is easy to list only your logs in android monitor in Android Studio. Sometimes you are running services or other classes simultaneously. If you have to search by activity name alone then you cannot see exactly when a service response was obtained and then an action from your activity has occurred. A prefix like CCC helps as it gives you logs chronologically with the activity in which it occured