0

在许多 shell 命令中,输出是连续的事件流,例如系统日志。我只需要查看现在或当前系统时间的输出。这是我从 adb logcat 得到的程序输出,

09-03 17:12:04.562   479   957 I ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.amazon.mShop.android/com.amazon.mShop.home.HomeActivity } from pid 1230
09-03 17:12:04.687   479  1030 I ActivityManager: Start proc com.amazon.mShop.android for activity com.amazon.mShop.android/com.amazon.mShop.home.HomeActivity: pid=19164 uid=10158 gids={1006, 3003}
09-03 17:12:05.593   479   912 I ActivityManager: Starting: Intent { dat=?paramSuggestionText=cell%20phone flg=0x20000 cmp=com.amazon.mShop.android/com.amazon.mShop.search.SearchActivity (has extras) } from pid 19164
09-03 17:12:05.796   479   620 I ActivityManager: Displayed com.amazon.mShop.android/com.amazon.mShop.search.SearchActivity: +186ms (total +1s119ms)
09-03 17:12:08.601   479   620 I ActivityManager: Displayed com.amazon.mShop.android/com.amazon.mShop.home.HomeActivity: +3s925ms
09-03 17:12:08.601   479   620 I ActivityManager: Resumed Activity: com.amazon.mShop.android/com.amazon.mShop.search.SearchActivity totalTime: 4037 ms
09-03 17:13:35.742   479   957 I ActivityManager: Starting: Intent { act=intentActionStartActivity flg=0x20000 cmp=com.amazon.mShop.android/com.amazon.mShop.categoryBrowse.CategoryBrowseActivity } from pid 19164
09-03 17:13:36.007   479   620 I ActivityManager: Displayed com.amazon.mShop.android/com.amazon.mShop.categoryBrowse.CategoryBrowseActivity: +222ms
09-03 17:13:53.328   479   957 I ActivityManager: Starting: Intent { dat=?&paramSuggestionFilters=s%3An%3A%2C%3A4991425011%0As%3An%3A%2C%3A4991426011%0As%3An%3A%2C%3A5088769011%0As%3An%3A%2C%3A5263615011&paramDepartmentName=Programs flg=0x20000 cmp=com.amazon.mShop.android/com.amazon.mShop.search.SearchActivity (has extras) } from pid 19164
09-03 17:13:53.484   479   620 I ActivityManager: Displayed com.amazon.mShop.android/com.amazon.mShop.search.SearchActivity: +145ms

它是一个连续流,显示系统启动时的事件,但我只需要来自当前系统时间的日志。那么,我该如何实现呢?

4

2 回答 2

1

根据adb手册,可以分两步执行此操作:

  1. 使用清除日志logcat -c
  2. 使用常规logcat调用进行持续日志监控

如果这应该结合在一起,我想只是运行logcat -c && logcat将是解决方案。

于 2012-09-21T02:42:08.550 回答
0

我的问题用 logcat -c 选项解决了。更通用的解决方案是使用 tail -f 命令行选项。虽然它不是超级准确但有效。

于 2012-09-25T04:36:24.153 回答