我刚看了一下源码和文档
01. public static int d(String tag, String msg) {
02. return println(DEBUG, tag, msg);复制代码在来看这个println怎么实现的:
103 static jint android_util_Log_println(JNIEnv* env, jobject clazz, 104 jint priority, jstring tagObj, jstring msgObj) 105 { 106 const char* tag = NULL; 107 const char* msg = NULL; 108 109 if (msgObj == NULL) { 110 jclass npeClazz; 111 112 npeClazz = env->FindClass("java/lang/NullPointerException"); 113 assert(npeClazz != NULL); 114 115 env->ThrowNew(npeClazz, "println needs a message"); 116 return -1; 117 } 118 119 if (tagObj != NULL) 120 tag = env->GetStringUTFChars(tagObj, NULL); 121 msg = env->GetStringUTFChars(msgObj, NULL); 122 123 int res = android_writeLog((android_LogPriority) priority, tag, msg); 124 125 if (tag != NULL) 126 env->ReleaseStringUTFChars(tagObj, tag); 127 env->ReleaseStringUTFChars(msgObj, msg); 128 129 return res; 130 }