ALOGE的定义包含路径

 

首先文件: frameworks/base/cmds/app_process/app_main.cpp

包含了: #include <utils/Log.h> 

并使用了ALOGE

69          char* slashClassName = toSlashClassName(mClassName.string());
70          mClass = env->FindClass(slashClassName);
71          if (mClass == NULL) {
72              ALOGE("ERROR: could not find class '%s'\n", mClassName.string());
73          }

第一步:全球搜索Log.h 命令 :   locate Log.h |grep \/utils\/Log.h

......

/mnt/extdisk/8/system/core/libutils/include/utils/Log.h
/mnt/extdisk/9/system/core/libutils/include/utils/Log.h

......

第二步:

cat /mnt/extdisk/9/system/core/libutils/include/utils/Log.h
// DO NOT INCLUDE ANYTHING NEW IN THIS FILE.

// <log/log.h> has replaced this file and all changes should go there instead.
// This path remains strictly to include that header as there are thousands of
// references to <utils/Log.h> in the tree.

#include <log/log.h>
==============================================

可见这是个中间文件

第三步 全球搜索log.h  : locate log.h |grep \/log\/log.h

locate log.h |grep \/log\/log.h

4,查看log.h

这里面没有关于ALOGE的定义

test@home:/mnt/extdisk/9$

再确认里面包含的头文件是否有:同样的方法[

4.1 locate log.h |grep \/androd\/log.h
再找到android/log.h 如下:

/mnt/extdisk/9/out/soong/ndk/sysroot/usr/include/android/log.h
/mnt/extdisk/9/system/core/include/android/log.h
/mnt/extdisk/9/system/core/liblog/include/android/log.h

搜索无任何结果:

cat xx.txt 
/mnt/extdisk/9/out/soong/ndk/sysroot/usr/include/android/log.h
/mnt/extdisk/9/system/core/include/android/log.h
/mnt/extdisk/9/system/core/liblog/include/android/log.h
test@home:/mnt/extdisk/9$ 
test@home:/mnt/extdisk/9$ cat xx.txt |xargs grep -rn ALOGE

test@home:/mnt/extdisk/9$

4.2  log_id.h 

/mnt/extdisk/9/system/core/liblog/include/log/log_id.h
/mnt/extdisk/9/system/core/liblog/include_vndk/log/log_id.h

test@home:/mnt/extdisk/9$ grep -rn ALOGE /mnt/extdisk/9/system/core/liblog/include/log/log_id.h /mnt/extdisk/9/system/core/liblog/include_vndk/log/log_id.h
test@home:/mnt/extdisk/9$ 

没有:

4.3  log_main.h

test@home:/mnt/extdisk/9/system/core$ find -name log_main.h |xargs grep -rn ALOGE
./liblog/include/log/log_main.h:241:#ifndef ALOGE
./liblog/include/log/log_main.h:242:#define ALOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__))
./liblog/include/log/log_main.h:245:#ifndef ALOGE_IF
./liblog/include/log/log_main.h:246:#define ALOGE_IF(cond, ...)                                                \
./liblog/include/log/log_main.h:293:#ifndef IF_ALOGE
./liblog/include/log/log_main.h:294:#define IF_ALOGE() IF_ALOG(LOG_ERROR, LOG_TAG)
./liblog/include_vndk/log/log_main.h:241:#ifndef ALOGE
./liblog/include_vndk/log/log_main.h:242:#define ALOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__))
./liblog/include_vndk/log/log_main.h:245:#ifndef ALOGE_IF
./liblog/include_vndk/log/log_main.h:246:#define ALOGE_IF(cond, ...)                                                \
./liblog/include_vndk/log/log_main.h:293:#ifndef IF_ALOGE
./liblog/include_vndk/log/log_main.h:294:#define IF_ALOGE() IF_ALOG(LOG_ERROR, LOG_TAG)
test@home:/mnt/extdisk/9/system/core$  

找到

 68 /*
 69  * Log macro that allows you to specify a number for the priority.
 70  */
 71 #ifndef LOG_PRI
 72 #define LOG_PRI(priority, tag, ...) android_printLog(priority, tag, __VA_ARGS__)
 73 #endif
 74 

 62 #define android_printLog(prio, tag, ...) \
 63   __android_log_print(prio, tag, __VA_ARGS__)
 64 
 

__android_log_print  jni 中能直接使用的打印封装。

491 LIBLOG_ABI_PUBLIC int __android_log_print(int prio, const char* tag,
492                                           const char* fmt, ...) {
493   va_list ap;
494   char buf[LOG_BUF_SIZE];
495 
496   va_start(ap, fmt);
497   vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
498   va_end(ap);
499 
500   return __android_log_write(prio, tag, buf);
501 }
......
411 LIBLOG_ABI_PUBLIC int __android_log_write(int prio, const char* tag,
412                                           const char* msg) {
413   return __android_log_buf_write(LOG_ID_MAIN, prio, tag, msg);
414 }
415 

416 LIBLOG_ABI_PUBLIC int __android_log_buf_write(int bufID, int prio,
417                                               const char* tag, const char* msg) {
418   struct iovec vec[3];
419   char tmp_tag[32];
420 

477   vec[2].iov_len = strlen(msg) + 1;
478 
479   return write_to_log(bufID, vec, 3);
480 }
481 

write_to_log 是个函数指针:默认 = __write_to_log_init

40 static int (*write_to_log)(log_id_t, struct iovec* vec,
 41                            size_t nr) = __write_to_log_init;


system/core/liblog$ grep -rn "write_to_log = "
logger_write.c:144:  write_to_log = __write_to_log_init;
logger_write.c:401:    write_to_log = __write_to_log_daemon;
logger_write.c:680:    write_to_log = __write_to_log_null;
logger_write.c:696:    write_to_log = __write_to_log_init;
logger_write.c:700:    write_to_log = __write_to_log_init;

385 static int __write_to_log_init(log_id_t log_id, struct iovec* vec, size_t nr) {
386   int ret, save_errno = errno;
387 
388   __android_log_lock();
389 
390   if (write_to_log == __write_to_log_init) {
391     ret = __write_to_log_initialize();
392     if (ret < 0) {
393       __android_log_unlock();
394       if (!list_empty(&__android_log_persist_write)) {
395         __write_to_log_daemon(log_id, vec, nr);
396       }
397       errno = save_errno;
398       return ret;
399     }
400 
401     write_to_log = __write_to_log_daemon;
402   }
403 
404   __android_log_unlock();
405 
406   ret = write_to_log(log_id, vec, nr);
407   errno = save_errno;
408   return ret;

diff --git a/include/log/log_main.h b/include/log/log_main.h
index c88fe72..36b368a 100644
--- a/include/log/log_main.h
+++ b/include/log/log_main.h
@@ -298,6 +298,9 @@ __BEGIN_DECLS
 #endif

 /* --------------------------------------------------------------------- */
+#ifndef ALOGX
+#define ALOGX(fmt, ...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, "%s +%d %s msg --> " fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__)
+#endif

 /*
  * Basic log message macro.

01-01 08:00:05.950  1881  1881 D appproc : frameworks/base/cmds/app_process/app_main.cpp +284 main msg --> -----------nice name = zygote
01-01 08:00:05.951  1902  1902 I android.hardware.tv.cec@1.0-service: Registration complete for android.hardware.tv.cec@1.0::IHdmiCec/default.
01-01 08:00:05.952  1881  1881 D appproc : frameworks/base/cmds/app_process/app_main.cpp +324 main msg --> >We're in zygote mode.
01-01 08:00:05.953  1881  1881 D appproc : frameworks/base/cmds/app_process/app_main.cpp +352 main msg --> zygote == true to start java clz: com.android.internal.os.ZygoteInit.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值