当标签以“IMS”开头时,为什么Logcat不打印日志?

时间:2016-04-07 06:56:57

标签: android android-studio logcat

当标签以“IMS”开头时,Logcat为什么不打印日志?

@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.btnOne:
            System.out.println("Button One log by sout");
            Log.e("IMSfsadfasdfasdf", "log by Log.e()");
            break;
        case R.id.btnTwo:
            System.out.println("Button Two log by sout");
            Log.e("MService", "log by Log.e()");
            break;
    }
}

日志:

04-07 15:05:48.838 4363-4363/com.licheedev.myapplication I/System.out: Button One log by sout
04-07 15:05:49.916 4363-4363/com.licheedev.myapplication I/System.out: Button Two log by sout
04-07 15:05:49.916 4363-4363/com.licheedev.myapplication E/MService: log by Log.e()
04-07 15:05:54.109 4363-4363/com.licheedev.myapplication I/System.out: Button Two log by sout
04-07 15:05:54.109 4363-4363/com.licheedev.myapplication E/MService: log by Log.e()
04-07 15:05:54.822 4363-4363/com.licheedev.myapplication I/System.out: Button One log by sout
04-07 15:05:55.638 4363-4363/com.licheedev.myapplication I/System.out: Button One log by sout

截图:

1 个答案:

答案 0 :(得分:10)

我不太确定,但我认为这与Android的日志机制中的这行代码有关。这是函数__android_log_write(prio, tag, buf);

/* XXX: This needs to go! */
if (!strcmp(tag, "HTC_RIL") ||
    !strncmp(tag, "RIL", 3) || /* Any log tag with "RIL" as the prefix */
    !strncmp(tag, "IMS", 3) || /* Any log tag with "IMS" as the prefix */
    !strcmp(tag, "AT") ||
    !strcmp(tag, "GSM") ||
    !strcmp(tag, "STK") ||
    !strcmp(tag, "CDMA") ||
    !strcmp(tag, "PHONE") ||
    !strcmp(tag, "SMS")) {
        log_id = LOG_ID_RADIO;
        // Inform third party apps/ril/radio.. to use Rlog or RLOG
        snprintf(tmp_tag, sizeof(tmp_tag), "use-Rlog/RLOG-%s", tag);
        tag = tmp_tag;
}

阅读this blog帖子了解详细信息。