初めに結論
android.util.Log
に渡す TAG は、23文字以下でなければならない。
もし TAG が23文字より長いと、(少なくとも android.util.Log.isLoggable()
では) IllegalArgumentException
が送出される。
(付録: 上限23文字を導出する計算式)
MAX_LOG_TAG_LENGTH = PROPERTY_KEY_MAX - sizeof(LOG_NAMESPACE)
= PROP_NAME_MAX - sizeof("log.tag.")
= 32 - 9
= 23
core/java/android/util/Log.java (217)
public static native boolean isLoggable(String tag, int level);
core/jni/android_util_Log.cpp (62)
if ((strlen(chars)+sizeof(LOG_NAMESPACE)) > PROPERTY_KEY_MAX) {
char buf2[200];
snprintf(buf2, sizeof(buf2),
"Log tag \"%s\" exceeds limit of %zu characters\n",
chars, PROPERTY_KEY_MAX - sizeof(LOG_NAMESPACE));
jniThrowException(env, "java/lang/IllegalArgumentException", buf2);
core/jni/android_util_Log.cpp (18)
#define LOG_NAMESPACE "log.tag."
libcutils/include/cutils/properties.h (36)
/* System properties are *small* name value pairs managed by the
** property service. If your data doesn't fit in the provided
** space it is not appropriate for a system property.
**
** WARNING: system/bionic/include/sys/system_properties.h also defines
** these, but with different names. (TODO: fix that)
*/
#define PROPERTY_KEY_MAX PROP_NAME_MAX
libc/include/sys/system_properties.h (72)
/* Deprecated. In Android O and above, there's no limit on property name length. */
#define PROP_NAME_MAX 32
0 件のコメント :
コメントを投稿