2

我可以看到 LOGV 消息是 USER 构建(在 logcat 中)。

在用户构建中,通常禁用详细日志记录?或者至少我是这么想的。我们如何确保我们的 LOGV 消息显示在 userdebug 而不是用户构建中?

谢谢 Himanshu

4

1 回答 1

0

构建您自己的 Log 类来检测它是否是调试构建,然后将其用于所有日志。

看看: http: //developer.android.com/reference/android/content/pm/PackageManager.html#getPackageInfo (java.lang.String,%20int )

http://developer.android.com/reference/android/content/pm/PackageInfo.html

http://developer.android.com/reference/android/content/pm/ApplicationInfo.html

它可能看起来像这样:

public void logv(String tag, String message) {

        if(isDebug()) {
            Log.v(tag,message);
        }

        private boolean isDebug() {
            return (0 != (myContext.getPackageManager().getPackageInfo("com.myapp",0).applicationInfo.flags &= ApplicationInfo.FLAG_DEBUGGABLE)); 
        }
    }
}

或者使用 Log.d 而不是 Log.v

于 2012-06-06T11:16:00.727 回答