Ben Edwards
Ben Edwards

Reputation: 455

turning on DEBUG for a class in android

I can turn on DEBUG for SQLiteQueryBuilder with

adb shell setprop log.tag.SQLiteQueryBuilder DEBUG

I was having problems with a Recyclerview and noticed there was a DEBUG attribute on it.

public class RecyclerView extends ViewGroup implements ScrollingView,
        NestedScrollingChild2, NestedScrollingChild3 {

    static final String TAG = "RecyclerView";

    static final boolean DEBUG = false;

So I tried

adb shell setprop log.tag.RecyclerView DEBUG

But I did not get any aditional debuging in Logcat even thought there are Log.d calles in it.

So what am I doing wrong.

To get to the chase what I am trying to do is try to work out exacly whitch recycler view is bering attached as I am having problems. However knowing how to generaly turn on debuging messages in any class with DEBUG attribure would be good.

done a load of googeling but no joy.

Upvotes: 0

Views: 127

Answers (1)

Morrison Chang
Morrison Chang

Reputation: 12121

Log.d isn't the function that allows for adb shell setprop <tag> DEBUG to work.

From: https://source.android.com/docs/core/tests/debug/understanding-logging#log-standards

if (Log.isLoggable("FOO_TAG", Log.VERBOSE)) {
  Log.v("FOO_TAG", "Message for logging.");
} 

You can see that the control mechanism is partially in android.util.Log.isLoggable along with other conditions.

So does androidx.recyclerview.widget.RecyclerView, a library that is added in when the app is compiled, rather than in the device/emulator framework ROM contain that function?

A quick search of: https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-master-dev/recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/RecyclerView.java

shows no entries of Log.isLoggable(...) in that particular class.

Personally any derived View class should have your own personal/app specific log string identifier for debugging.

Upvotes: 1

Related Questions