logcat 流程

logcat的流程

1

static jint android_util_Log_println_native(JNIEnv* env, jobject clazz,  
        jint bufID, jint priority, jstring tagObj, jstring msgObj)  
{  
    const char* tag = NULL;  
    const char* msg = NULL;  
  
    if (msgObj == NULL) {  
        jniThrowNullPointerException(env, "println needs a message");  
        return -1;  
    }  
  
    if (bufID < 0 || bufID >= LOG_ID_MAX) {  
        jniThrowNullPointerException(env, "bad bufID");  
        return -1;  
    }  
  
    if (tagObj != NULL)  
        tag = env->GetStringUTFChars(tagObj, NULL);  
    msg = env->GetStringUTFChars(msgObj, NULL);  
  
    int res = __android_log_buf_write(bufID, (android_LogPriority)priority, tag, msg);  
  
    if (tag != NULL)  
        env->ReleaseStringUTFChars(tagObj, tag);  
    env->ReleaseStringUTFChars(msgObj, msg);  
  
    return res;  
}  

2

int __android_log_buf_write(int bufID, int prio, const char *tag, const char *msg)  
{  
    struct iovec vec[3];  
    char tmp_tag[32];  
  
    if (!tag)  
        tag = "";  
  
    /* XXX: This needs to go! */  
    if ((bufID != LOG_ID_RADIO) &&  
         (!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"))) {  
            bufID = LOG_ID_RADIO;//这些tag也归类到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;  
    }  
  
#if __BIONIC__  
    if (prio == ANDROID_LOG_FATAL) {  
        android_set_abort_message(msg);  
    }  
#endif  
  
    vec[0].iov_base   = (unsigned char *) &prio;  
    vec[0].iov_len    = 1;  
    vec[1].iov_base   = (void *) tag;  
    vec[1].iov_len    = strlen(tag) + 1;  
    vec[2].iov_base   = (void *) msg;  
    vec[2].iov_len    = strlen(msg) + 1;  
  
    return write_to_log(bufID, vec, 3);  
}  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值