本文搜集网上知识,记录android学习中的一些知识点

  logcat:

// java层的logcat我们不谈,看native层:/system/core/include/log/log.h以ALOGV()为例,
/*
50 * Normally we strip ALOGV (VERBOSE messages) from release builds.
51 * You can modify this (for example with "#define LOG_NDEBUG 0"
52 * at the top of your source file) to change that behavior.
53 */
#ifndef LOG_NDEBUG
#ifdef NDEBUG
#define LOG_NDEBUG 1
#else
#define LOG_NDEBUG 0
#endif
#endif

#ifndef ALOGV
#if LOG_NDEBUG
#define ALOGV(...)   ((void)0)
#else
#define ALOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
#endif
#endif
// 需设置#define LOG_NDEBUG 0才能输出系统的ALOGV()信息
#define ALOG(priority, tag, ...) \
    LOG_PRI(ANDROID_##priority, tag, __VA_ARGS__)
#endif
/*
 * Log macro that allows you to specify a number for the priority.
 */
#ifndef LOG_PRI
#define LOG_PRI(priority, tag, ...) \
    android_printLog(priority, tag, __VA_ARGS__)
#endif
// 你可以看看从ALOGV一直到__android_log_print,
// 而__android_log_print就关联的日志的写文件操作,这里我们先不提
#define android_printLog(prio, tag, fmt...) \
    __android_log_print(prio, tag, fmt)
    
// 接下来我们看看系统中的logcat文件 
$ adb shell dmesg > dmesg.txt   linux内核启动log,init进程log
$ adb logcat -d -v time -b "main"   >  main.txt  Zygote进程log
$ adb logcat -d -v time -b "system" >  system.txt SystemServer进程的log
$ adb logcat -d -v time -b "events" >   events .txt 
// 详情看 Android内核开发:学会分析系统启动log http://ticktick.blog.51cto.com/823160/1662911
View Code

相关文章: