How do you usually Tag log entries? (android)

后端 未结 13 1566
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-22 21:54

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

13条回答
  •  感情败类
    2020-12-22 22:03

    AndroidStudio has a logt template by default (you can type logtand press tab to have it expand to a sinppet of code) . I recommend using this to avoid copy pasting the TAG definition from another class and forgetting to change the class you're referring to. The template expands by default to

    private static final String TAG = "$CLASS_NAME$"

    To avoid using the old class name after refactoring you could change that to

    private static final String TAG = $CLASS_NAME$.class.getSimpleName();

    Remember to check the "Edit variables" button and make sure that the CLASS_NAME variable is defined to use the className() Expression and has "Skip if defined" checked.

提交回复
热议问题