转载来源:https://blog.csdn.net/yfbdxz/article/details/114702144
- 用EventLog.writeEvent打的日志(或EventLogTags.java方法打的日志),可以用logcat -b events查看
frameworks/base/core/java/android/util/EventLog.java
//tag:The event type tag code. value:value to log
public static native int writeEvent(int tag,var value);
public static native void readEvents(int[] tags,Collection<Event> output);
//从system/etc/event-log-tags读后同时放到了sTagCodes,sTagNames两个map中
private static final String TAGS_FILE = "/system/etc/event-log-tags";
private static HashMap<String,Integer> sTagCodes = null;
private static HashMap<Integer,String> sTagNames = null;
- EventLogTags.logtags 很多模块有该文件,writeEvent()参数tag value也是在其中被声明的
packages/providers/BlacklistProvider/src/com/android/providers/black/EventLogTags.logtags
packages/providers/CalendarProvider/src/com/android/providers/calendar/EventLogTags.logtags
packages/providers/ContactsProvider/src/com/android/providers/contacts/EventLogTags.logtags
packages/services/Telephony/src/com/android/phone/EventLogTags.logtags
packages/apps/Settings/src/com/android/settings/EventLogTags.logtags
packages/apps/QuickSearchBox/src/com/android/quicksearchBox/EventLogTags.logtags
frameworks/base/services/core/java/com/android/server/EventLogTags.logtags
frameworks/base/services/core/java/com/android/server/am/EventLogTags.logtags
frameworks/base/packages/systemUI/src/com/android/systemUI/EventLogTags.logtags
- EventLogTags.logtags在Android.mk中配置
logcat中LOCAL_SRC_FILES:= logcat.cpp event.logtags
systemUI中LOCAL_SRC_FILES := src/com/android/systemUI/EventLogTags.logtags
- EventLogTags.logtags文件格式说明
每一行大致三部分组成: Tag numbers + Tag names + (<名字>|数据类型[|数据单位]),(<名字>|数据类型[|数据单位])
logcat打印内容就是第二部分+第三部分
详见:android/system/core/logcat/event.logtags
- EventLogTags.logtags编译时被翻译成了java
frameworks/base/core/java/com/android/internal/logging/EventLogTags.logtags
option java_package com.android.internal.logging;
524287 sysui_view_visibility (category|1|5),(visible|1|6)
524288 sysui_action (category|1|5),(pkg|3)
524290 sysui_count (name|3),(increment|1)
524291 sysui_histogram (name|3),(bucket|1)
out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/.../logging/EventLogTags.java
public class EventLogTags {
private EventLogTags() { } // don't instantiate
/** 524287 sysui_view_visibility (category|1|5),(visible|1|6) */
public static final int SYSUI_VIEW_VISIBILITY = 524287;
/** 524288 sysui_action (category|1|5),(pkg|3) */
public static final int SYSUI_ACTION = 524288;
/** 524290 sysui_count (name|3),(increment|1) */
public static final int SYSUI_COUNT = 524290;
/** 524291 sysui_histogram (name|3),(bucket|1) */
public static final int SYSUI_HISTOGRAM = 524291;
public static void writeSysuiViewVisibility(int category,int visible) {
android.util.EventLog.writeEvent(SYSUI_VIEW_VISIBILITY,category,visible);
}
public static void writeSysuiAction(int category,String pkg) {
android.util.EventLog.writeEvent(SYSUI_ACTION,pkg);
}
public static void writeSysuiCount(String name,int increment) {
android.util.EventLog.writeEvent(SYSUI_COUNT,name,increment);
}
public static void writeSysuiHistogram(String name,int bucket) {
android.util.EventLog.writeEvent(SYSUI_HISTOGRAM,bucket);
}
}
- EventLogTags.logtags相关脚本
android/build/tools 目录下有三个event_log相关的脚本
event_log_tags.py //读取跟解析event_log_tags文件
java-event-log-tags.py //把EventLogTags.logtags文件翻成java
merge-event-log-tags.py //把多个EventLogTags.logtags合并成一个,并检查number冲突
merge-event-log-tags.py使用及/system/etc/event-log-tags文件创建时间点
详见:android/build/core/Makefile -- .PHONY: event-log-tags
遗留:event-log-tags被使用细节?其他两个py被使用时间点?
原文链接:https://www.cnblogs.com/Bolia/p/17958677