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 your logs in your applications? I've seen some hardcode like this:
public class MyActivity extends Activity {
private static final String TAG = "MyActivity";
//...
public void method () {
//...
Log.d(TAG, "Some logging");
}
}
This doesn't look nice because of many reasons:
- You can tell me this code doesn't have hardcode, but it does.
- My application could have any number of classes in different packages with the same name. So it would be hard to read the log.
- It isn't flexible. You always have put a private field TAG into your class.
Is there any neat way to get a TAG for a class?