【Android日志分析】EventLog

Android源码中有大量的EventLog日志,通过这个日志可以很简洁的呈现出系统的事件处理流程,包括时间,状态,便于我们分析定位问题。

  • 命令
查看Event所有的tags
adb shell cat /system/etc/event-log-tags

输出events日志信息
adb logcat -b events

该命令会输出带有时间点、进程号等信息的events log
adb logcat -v threadtime -t 4096 -b events
  • EventLogs完整语义分析
30014 am_proc_start (User|1|5),(PID|1|5),(UID|1|5),(Process Name|3),(Type|3),(Component|3)

格式:(|data type[|data unit]) ==> (<名字>|数据类型[|数据单位])

例子:(User|1|5) ==> 名字为User, 数据类型为1,数据单位为5,下面再来看看数据类型和数据单位

数据类型:1:int,2:long,3:string,4:list

数据单位:1:对象个数,2:字节数,3:毫秒,4:分配个数,5:ID,6百分比

实例分析:
am_proc_start (User|1|5),(PID|1|5),(UID|1|5),(Process Name|3),(Type|3),(Component|3) am_proc_start: [0,9227,10002,com.android.browser,content provider,com.android.browser/.provider.BrowserProvider2] 

进程启动: UserId=0, pid=9227, uid=10002, ProcessName=com.android.browser, 
数据类型=ContentProvider, 组件=com.android.browser/.provider.BrowserProvider2

更多格式参考下面的列表

  • EventLogs格式整理
AM
30001	am_finish_activity	User,Token,TaskID,ComponentName,Reason
30002	am_task_to_front	User,Task
30003	am_new_intent	User,Token,TaskID,ComponentName,Action,MIMEType,URI,Flags	
30004	am_create_task	User ,Task ID
30005	am_create_activity	User ,Token ,TaskID ,ComponentName,Action,MIMEType,URI,Flags
30006	am_restart_activity	User ,Token ,TaskID,ComponentName
30007	am_resume_activity	User ,Token ,TaskID,ComponentName
30008	am_anr	User ,pid ,Package Name,Flags ,reason
30009	am_activity_launch_time	User ,Token ,ComponentName,time
30010	am_proc_bound	User ,PID ,ProcessName
30011	am_proc_died	User ,PID ,ProcessName
30012	am_failed_to_pause	User ,Token ,Wanting to pause,Currently pausing
30013	am_pause_activity	User ,Token ,ComponentName
30014	am_proc_start	User ,PID ,UID ,ProcessName,Type,Component
30015	am_proc_bad	User ,UID ,ProcessName
30016	am_proc_good	User ,UID ,ProcessName
30017	am_low_memory	NumProcesses
30018	am_destroy_activity	User ,Token ,TaskID,ComponentName,Reason
30019	am_relaunch_resume_activity	User ,Token ,TaskID,ComponentName
30020	am_relaunch_activity	User ,Token ,TaskID,ComponentName
30021	am_on_paused_called	User ,ComponentName
30022	am_on_resume_called	User ,ComponentName
30023	am_kill	User ,PID ,ProcessName,OomAdj ,Reason
30024	am_broadcast_discard_filter	User ,Broadcast ,Action,ReceiverNumber,BroadcastFilter
30025	am_broadcast_discard_app	User ,Broadcast ,Action,ReceiverNumber,App
30030	am_create_service	User ,ServiceRecord ,Name,UID ,PID
30031	am_destroy_service	User ,ServiceRecord ,PID
30032	am_process_crashed_too_much	User ,Name,PID
30033	am_drop_process	PID
30034	am_service_crashed_too_much	User ,Crash Count,ComponentName,PID
30035	am_schedule_service_restart	User ,ComponentName,Time
30036	am_provider_lost_process	User ,Package Name,UID ,Name
30037	am_process_start_timeout	User ,PID ,UID ,ProcessName
30039	am_crash	User ,PID ,ProcessName,Flags ,Exception,Message,File,Line
30040	am_wtf	User ,PID ,ProcessName,Flags ,Tag,Message
30041	am_switch_user	id
30042	am_activity_fully_drawn_time	User ,Token ,ComponentName,time
30043	am_focused_activity	User ,ComponentName
30044	am_home_stack_moved	User ,To Front ,Top Stack Id ,Focused Stack Id ,Reason
30045	am_pre_boot	User ,Package
30046	am_meminfo	Cached,Free,Zram,Kernel,Native
30047	am_pss	Pid, UID, ProcessName, Pss, Uss

Power
2722	battery_level	level, voltage, temperature
battery_level: [19,3660,352] //剩余电量19%, 电池电压3.66v, 电池温度35.2℃
2723	battery_status	status,health,present,plugged,technology	
2730	battery_discharge	duration, minLevel,maxLevel
2724	power_sleep_requested	wakeLocksCleared
2725	power_screen_broadcast_send	wakelockCount
2726	power_screen_broadcast_done	on, broadcastDuration, wakelockCount	
2727	power_screen_broadcast_stop	which,wakelockCount
2728	power_screen_state	offOrOn, becauseOfUser, totalTouchDownTime, touchCycles
power_screen_state: [0,3,0,0] // 灭屏状态(0), 屏幕超时(3). 当然还有其他设备管理策略(1),其他理由都为用户行为(2)
2729	power_partial_wake_state	releasedorAcquired, tag

后续会继续补充...
  • 各个TAG使用的一些场景
TAG 位置
am_low_memory AMS.killAllBackgroundProcesses或者AMS.appDiedLocked,记录当前Lru进程队列长度
am_pss AMS.recordPssSampleLocked
am_meminfo AMS.dumpApplicationMemoryUsage
am_proc_start AMS.startProcessLocked
am_proc_bound AMS.attachApplicationLocked
am_kill ProcessRecord.kill,杀掉进程
am_anr AMS.appNotResponding
am_crash AMS.handleApplicationCrashInner
am_wtf AMS.handleApplicationWtf
am_activity_launch_time ActivityRecord.reportLaunchTimeLocked(),后面两个参数分别是thisTime和 totalTime
am_activity_fully_drawn_time ActivityRecord.reportFullyDrawnLocked, 后面两个参数分别是thisTime和 totalTime
am_broadcast_discard_filter BroadcastQueue.logBroadcastReceiverDiscardLocked
am_broadcast_discard_app BroadcastQueue.logBroadcastReceiverDiscardLocked
am_on_resume_called AT.performResumeActivity
am_on_paused_called AT.performPauseActivity, performDestroyActivity
am_resume_activity AS.resumeTopActivityInnerLocked
am_pause_activity AS.startPausingLocked
am_finish_activity AS.finishActivityLocked, removeHistoryRecordsForAppLocked
am_destroy_activity AS.destroyActivityLocked
am_focused_activity AMS.setFocusedActivityLocked, clearFocusedActivity
am_restart_activity ASS.realStartActivityLocked
am_create_activity ASS.startActivityUncheckedLocked
am_new_intent ASS.startActivityUncheckedLocked
am_task_to_front AS.moveTaskToFrontLocked

先整理这些,后续会继续补充,主要是为了便于自己记录使用

 

Android性能优化归纳总结

Android源码 权限验证分析(一)

【Android日志分析】Battery Historian功耗分析工具

你可能感兴趣的:(Android,编程,Android,源码分析,Android日志,EventLog,日志分析)