adb locat 过滤日志-命令行

记录:跟同事去测试那现场看log,从终端过滤命令不太熟练
参考连接:https://www.cnblogs.com/zhengah/p/4565624.html
android输出的每一条日志都有一个标记和优先级与其关联。

优先级是下面的字符,顺序是从低到高:
V — 明细 verbose(最低优先级)
D — 调试 debug
I — 信息 info
W — 警告 warn
E — 错误 error
F — 严重错误 fatal
S — 无记载 silent

1、只显示需要的输出(白名单)

adb logcat | grep CloudSDK
adb logcat | grep "CloudSDK"
adb logcat | grep -i cloudsdk #忽略大小写。
adb logcat | grep " ..oud"   # 省略前俩字符,从第三个字符开始

adb logcat *:E |grep CloudSDK      //显示所有优先级大于等于Error 的日志
adb logcat *:E |grep -i cloudsdk

adb logcat | grep "I.CloudSDK"   //输出级别为Info的 tag为CloudSDK的命令行
adb logcat | grep "E.CloudSDK"   //输出级别为Error的 tag为CloudSDK的命令行
adb logcat CloudSDK:E *:S         //输出级别大于等于Error的 tag为CloudSDK的命令行


//使用 | 分割多个匹配表达式,要加转义符。例如要匹配 tag 为 System.err 和 CloudSDK 的输出:
adb logcat | grep  " System.err\| CloudSDK"      #  \| 为转义符
adb logcat | grep -E "System.err|CloudSDK"    #  使用 egrep 无须转义符

//-s: 设置输出日志的标签, 只显示该标签的日志;所有级别的
adb logcat -s CloudSDK
adb logcat -s "xxxx | CloudSDK"//查找xxxx和CloudSDK为tag的日志
adb logcat -s ActivityManager:I   //输出标记为“ActivityManager”且优先级大于等于“Info”的日志

//仅输出标记为“ActivityManager”且优先级大于等于“Info”和标记为“PowerManagerService”并且优先级大于等于“Debug”的日志:

adb logcat ActivityManager:I PowerManagerService:D *:S
注:*:S用于设置所有标记的日志优先级为S,这样可以确保仅输出符合条件的日志。

2、过滤不需要的输出(黑名单)
还是使用 grep,用法也跟上面的一样,加一个 -v 即可。例如要过滤 tag 为 System.err 和 CloudSDK 的输出:

adb logcat | grep -v "CloudSDK\|System.err"
adb logcat | grep -vE "CloudSDK|System.err"

3、显示同一个进程的所有输出
有时一个程序里面的 tag 有多个,需要输出该程序(同一个 PID)的所有 tag;仅使用 tag 过滤有时也会漏掉一些错误信息,而一般错误信息也是和程序同一个 PID。还是通过 grep 实现,思路是先根据包名找到 pid 号,然后匹配 pid。写成 shell 脚本如下,参数是程序的 java 包名(如 com.android.media)。

 #!/bin/bash
       packageName=$1
       pid=`adb shell ps | grep $packageName | awk ‘{print $2}’`
       adb logcat | grep –color=auto $pid

4、从当前开始显示

logcat 有缓存,如果仅需要查看当前开始的 log,需要清空之前的。

 adb logcat -c && adb logcat|grep  "CloudSDK" 

5、保存日志到文件

adb logcat > test.log //将日志保存到文件test.log

adb logcat | grep CloudSDK > test1.log

在window上
C:\Users\xxxxx\Desktop>adb logcat | findStr CloudSDK > test.log

6、可以同时设置多个过滤器
输出 CloudSDK 标签 的 Error以上级别 和 System.err 标签的 warn 以上级别的日志;

adb logcat CloudSDK:E System.err:W *:S

来源链接:https://www.runoob.com/linux/linux-comm-grep.html

Grep命令
Linux grep 命令用于查找文件里符合条件的字符串。

grep 指令用于查找内容包含指定的范本样式的文件,如果发现某文件的内容符合所指定的范本样式,预设 grep 指令会把含有范本样式的那一列显示出来。若不指定任何文件名称,或是所给予的文件名为 -,则 grep 指令会从标准输入设备读取数据。
语法

grep [-abcEFGhHilLnqrsvVwxy][-A<显示列数>][-B<显示列数>][-C<显示列数>][-d<进行动作>][-e<范本样式>][-f<范本文件>][--help][范本样式][文件或目录...]

参数:

-a 或 --text : 不要忽略二进制的数据。
-A<显示行数>--after-context=<显示行数> : 除了显示符合范本样式的那一列之外,并显示该行之后的内容。
-b 或 --byte-offset : 在显示符合样式的那一行之前,标示出该行第一个字符的编号。
-B<显示行数>--before-context=<显示行数> : 除了显示符合样式的那一行之外,并显示该行之前的内容。
-c 或 --count : 计算符合样式的列数。
-C<显示行数>--context=<显示行数>-<显示行数> : 除了显示符合样式的那一行之外,并显示该行之前后的内容。
-d <动作>--directories=<动作> : 当指定要查找的是目录而非文件时,必须使用这项参数,否则grep指令将回报信息并停止动作。
-e<范本样式>--regexp=<范本样式> : 指定字符串做为查找文件内容的样式。
-E 或 --extended-regexp : 将样式为延伸的正则表达式来使用。
-f<规则文件>--file=<规则文件> : 指定规则文件,其内容含有一个或多个规则样式,让grep查找符合规则条件的文件内容,格式为每行一个规则样式。
-F 或 --fixed-regexp : 将样式视为固定字符串的列表。
-G 或 --basic-regexp : 将样式视为普通的表示法来使用。
-h 或 --no-filename : 在显示符合样式的那一行之前,不标示该行所属的文件名称。
-H 或 --with-filename : 在显示符合样式的那一行之前,表示该行所属的文件名称。
-i 或 --ignore-case : 忽略字符大小写的差别。
-l 或 --file-with-matches : 列出文件内容符合指定的样式的文件名称。
-L 或 --files-without-match : 列出文件内容不符合指定的样式的文件名称。
-n 或 --line-number : 在显示符合样式的那一行之前,标示出该行的列数编号。
-o 或 --only-matching : 只显示匹配PATTERN 部分。
-q 或 --quiet或--silent : 不显示任何信息。
-r 或 --recursive : 此参数的效果和指定"-d recurse"参数相同。
-s 或 --no-messages : 不显示错误信息。
-v 或 --revert-match : 显示不包含匹配文本的所有行。
-V 或 --version : 显示版本信息。
-w 或 --word-regexp : 只显示全字符合的列。
-x --line-regexp : 只显示全列符合的列。
-y : 此参数的效果和指定"-i"参数相同

参考链接:https://blog.csdn.net/lwz622/article/details/84403088

Logcat命令列表:

--"-s"选项 : 设置输出日志*:s的标签, 只显示该标签的日志;
--"-d" 将日志显示在控制台后退出
--"-c" 清理已存在的日志
--"-f <filename>" 将日志输出到文件
adb logcat -f /sdcard/test.txt

-v <format>设置日志输入格式控制输出字段,默认的是brief格式
	brief — 显示优先级/标记和原始进程的PID (默认格式)
	process — 仅显示进程PID
	tag — 仅显示优先级/标记
	thread — 仅显示进程:线程和优先级/标记
	raw — 显示原始的日志信息,没有其他的元数据字段
	time — 显示日期,调用时间,优先级/标记,PID
	long —显示所有的元数据字段并且用空行分隔消息内容


adb logcat -v thread   //使用 thread 输出格式
注意-v 选项中只能指定一种格式。

-b <buffer>加载一个可使用的日志缓冲区供查看,默认值是main。
	radio — 查看包含在无线/电话相关的缓冲区消息
	events — 查看事件相关的消息
	main — 查看主缓冲区 (默认缓冲区)

adb logcat -b radio     //查看radio缓冲区

--"-r"选项 : 按照每千字节输出日志, 需要 -f 参数, 不过这个命令没有执行成功;
--"-n"选项 : 设置日志输出的最大数目, 需要 -r 参数, 这个执行 感觉 跟 adb logcat 效果一样;

--"-d"选项 : 将缓存的日志输出到屏幕上, 并且不会阻塞;
--"-t"选项 : 输出最近的几行日志, 输出完退出, 不阻塞;
--"-g"选项 : 查看日志缓冲区信息;
--"-B"选项 : 以二进制形式输出日志;

输出指定标签内容 :

– "-s"选项 : 设置默认的过滤器, 如 我们想要输出 “System.out” 标签的信息, 就可以使用 adb logcat -s System.out 命令;

octopus@octopus:~$ adb logcat -s System.out  
--------- beginning of /dev/log/system  
--------- beginning of /dev/log/main  
I/System.out(22930): GSM -91  
I/System.out(22930): SignalStrength issssssssss : -91  
I/System.out(22930): GSM -91  
I/System.out(22930): SignalStrength issssssssss : -91  
I/System.out(22930): Supervisor Thread  
I/System.out(22930): Got run mode  

输出日志信息到文件 :

– "-f"选项 : 该选向后面跟着输入日志的文件, 使用 adb logcat -f log 命令, 会出现错误, 这里我们不推荐使用该选项

octopus@octopus:~$ adb logcat -f log  
couldn't open output file: Read-only file system  

– ">"输出 : “>” 后面跟着要输出的日志文件, 可以将 logcat 日志输出到文件中, 使用 adb logcat > log 命令, 使用 more log 命令查看日志信息;

octopus@octopus:~$ adb logcat > log  
^C  
octopus@octopus:~$ more log  
--------- beginning of /dev/log/system  
V/ActivityManager(  500): We have pending thumbnails: null  
V/ActivityManager(  500): getTasks: max=1, flags=0, receiver=null  
V/ActivityManager(  500): com.android.settings/.Settings: task=TaskRecord{42392278 #448 A com.android.settings U 0}  
V/ActivityManager(  500): We have pending thumbnails: null

指定 logcat 的日志输出格式 :

– "-v"选项 : 使用 adb logcat -v time 命令, 可以啥看日志的输出时间;

– "brief"格式 : 这是默认的日志格式 " 优先级 / 标签 (进程ID) : 日志信息 ", 使用 adb logcat -v prief 命令;

octopus@octopus:~$ adb logcat -v brief  
--------- beginning of /dev/log/system  
D/PowerManagerService(  500): handleSandman: canDream=true, mWakefulness=Awake  
D/PowerManagerService(  500): releaseWakeLockInternal: lock=1101267696, flags=0x0 

– "process"格式 : " 优先级 (进程ID) : 日志信息 ", 使用 adb logcat -v process 命令;

octopus@octopus:~$ adb logcat -v process  
--------- beginning of /dev/log/system  
D(  500) MobileDataStateReceiver received: ACTION_ANY_DATA_CONNECTION_STATE_CHANGED_MOBILE [wap]  (MobileDataStateTracker)  
V(  500) Broadcast: Intent { act=android.intent.action.ANY_DATA_STATE_MOBILE flg=0x10 (has extras) } ordered=true userid=0  (ActivityManager)  
D(  500) wap: Intent from SIM 0, current SIM 0, current DataState DISCONNECTED  (MobileDataStateTracker)  
D(  500) wap: wap setting isAvailable to false  (MobileDataStateTracker)  
D(  500) wap: Received state=DISCONNECTED, old=DISCONNECTED, reason=dataDetached  (MobileDataStateTracker)  
D(  500) BDC-Calling finishReceiver: IIntentReceiver=41c46ba0  (ActivityThread)  

– “tag"格式 : " 优先级 / 标签 : 日志信息”, 使用 adb logcat -v tag 命令;

octopus@octopus:~$ adb logcat -v tag  
--------- beginning of /dev/log/system  
I/PowerManagerService: setBrightness mButtonLight 0.  
D/PowerManagerService: updateScreenStateLocked: mDisplayReady=true, newScreenState=2, mWakefulness=1, mWakeLockSummary=0x1, mUserActivitySummary=0x1, mBootCompleted=true  
D/PowerManagerService: handleSandman: canDream=true, mWakefulness=Awake  

– "thread"格式 : " 优先级 ( 进程ID : 线程ID) 标签 : 日志内容 ", 使用 adb logcat -v tag 命令;

octopus@octopus:~$ adb logcat -v thread  
--------- beginning of /dev/log/system  
V(  500: 2141) getTasks: max=1, flags=0, receiver=null  
V(  500: 2141) com.lewa.launcher/.Launcher: task=TaskRecord{41dccc20 #425 A com.lewa.launcher U 0}  
V(  500: 2141) We have pending thumbnails: null  
V(  500: 2140) getTasks: max=1, flags=0, receiver=null  

– "raw"格式 : 只输出日志信息, 不附加任何其他 信息, 如 优先级 标签等, 使用 adb logcat -v raw 命令;

octopus@octopus:~$ adb logcat -v raw  
--------- beginning of /dev/log/system  
notifications are enabled for com.kindroid.security  
Assigned score=0 to Notification(pri=0 contentView=com.kindroid.security/0x7f030052 vibrate=null sound=null defaults=0x0 flags=0x2 kind=[null])  
Native set alarm :Alarm{41e1ca00 type 3 com.kindroid.security}  
reset poweroff alarm none  

– "time"格式 : "日期 时间 优先级 / 标签 (进程ID) : 进程名称 : 日志信息 " , 使用 adb logcat -v time 命令;

octopus@octopus:~$ adb logcat -v time  
--------- beginning of /dev/log/system  
04-25 17:18:13.019 V/ActivityManager(  500): Broadcast sticky: Intent { act=android.intent.action.SIG_STR flg=0x10 (has extras) } ordered=false userid=-1  
04-25 17:18:13.157 V/NotificationService(  500): enqueueNotificationInternal: pkg=com.kindroid.security id=1020 notification=Notification(pri=0 contentView=com.kindroid.security/0x7f030052 vibrate=null sound=null defaults=0x0 flags=0x2 kind=[null])  
04-25 17:18:13.158 V/NotificationService(  500): notifications are enabled for com.kindroid.security  
04-25 17:18:13.158 V/NotificationService(  500): Assigned score=0 to Notification(pri=0 contentView=com.kindroid.security/0x7f030052 vibrate=null sound=null defaults=0x0 flags=0x2 kind=[null])  
04-25 17:18:13.555 V/ActivityManager(  500): getTasks: max=1, flags=0, receiver=null  

– "long"格式 : " [ 日期 时间 进程ID : 线程ID 优先级 / 标签] 日志信息 ", 输出以上提到的所有的头信息, 使用 adb logcat -v long 命令;

octopus@octopus:~$ adb logcat -v long  
--------- beginning of /dev/log/system  
[ 04-25 17:21:18.118   500:0x2fe V/ActivityManager ]  
We have pending thumbnails: null  
  
[ 04-25 17:21:18.696   593:0x251 W/ActivityThread ]  
Content provider com.android.providers.telephony.TelephonyProvider already published as telephony  
  
[ 04-25 17:21:19.119   500:0x396 V/ActivityManager ]  
getTasks: max=1, flags=0, receiver=null  

清空日志缓存信息 : 使用 adb logcat -c 命令, 可以将之前的日志信息清空, 重新开始输出日志信息;

将缓存日志输出 : 使用 adb logcat -d 命令, 输出命令, 之后推出命令, 不会进行阻塞;

输出最近的日志 : 使用 adb logcat -t 5 命令, 可以输出最近的5行日志, 并且不会阻塞;

octopus@octopus:~$ adb logcat -t 5  
--------- beginning of /dev/log/system  
--------- beginning of /dev/log/main  
W/ADB_SERVICES(10028): adb: unable to open /proc/10028/oom_adj  
D/dalvikvm(23292): threadid=11: created from interp  
D/dalvikvm(23292): start new thread  
D/dalvikvm(23292): threadid=11: notify debugger  
D/dalvikvm(23292): threadid=11 (Thread-24538): calling run()  
octopus@octopus:~$   

查看日志缓冲区信息 : 使用 adb logcat -g 命令;

octopus@octopus:~$ adb logcat -g  
/dev/log/main: ring buffer is 256Kb (255Kb consumed), max entry is 5120b, max payload is 4076b  
/dev/log/system: ring buffer is 256Kb (255Kb consumed), max entry is 5120b, max payload is 4076b  
octopus@octopus:~$  

加载日志缓冲区 : 使用 adb logcat -b 缓冲区类型 命令;

– Android中的日志缓冲区 : system缓冲区 - 与系统相关的日志信息, radio缓冲区 - 广播电话相关的日志信息, events缓冲区 - 事件相关的日志信息, main缓冲区 - 默认的缓冲区;

octopus@octopus:~$ adb logcat -b radio -t 5  
D/PHONE   (23599): [GeminiDataSubUtil] UAPP_C6-4  
D/GSM     (23599): [GDCT][simId1]apnType = default  
D/GSM     (23599): [GDCT][simId1]isDataAllowed: not allowed due to - gprs= 1 - SIM not loaded - desiredPowerState= false  
D/GSM     (23599): [GDCT][simId1]isDataPossible(default): possible=false isDataAllowed=false apnTypePossible=true apnContextisEnabled=true apnContextState()=IDLE  
I/MUXD    (23591): [gsm0710muxd] 3426:main(): Frames received/dropped: 18242/0  
octopus@octopus:~$   
octopus@octopus:~$ adb logcat -b main -t 5  
D/NotificationService(  500): notification.sound=null  
D/NotificationService(  500): mDmLock=false  
I/ATCIJ   (16576): Couldn't find 'atci-serv-fw' socket; retrying after timeout  
W/ADB_SERVICES(  246): create_local_service_socket() name=shell:export ANDROID_LOG_TAGS="" ; exec logcat -b main -t 5  
W/ADB_SERVICES(16815): adb: unable to open /proc/16815/oom_adj  
octopus@octopus:~$   
octopus@octopus:~$ adb logcat -b system -t 5  
D/PowerManagerService(  500): updateScreenStateLocked: mDisplayReady=true, newScreenState=0, mWakefulness=0, mWakeLockSummary=0x1, mUserActivitySummary=0x0, mBootCompleted=true  
D/PowerManagerService(  500): handleSandman: canDream=false, mWakefulness=Asleep  
V/NotificationService(  500): enqueueNotificationInternal: pkg=com.kindroid.security id=1020 notification=Notification(pri=0 contentView=com.kindroid.security/0x7f030052 vibrate=null sound=null defaults=0x0 flags=0x2 kind=[null])  
V/NotificationService(  500): notifications are enabled for com.kindroid.security  
V/NotificationService(  500): Assigned score=0 to Notification(pri=0 contentView=com.kindroid.security/0x7f030052 vibrate=null sound=null defaults=0x0 flags=0x2 kind=[null])  
octopus@octopus:~$   
octopus@octopus:~$ adb logcat -b event -t 5  
Unable to open log device '/dev/log/event': No such file or directory  
octopus@octopus:~$ adb logcat -b events -t 5  
I/notification_cancel(  500): [com.kindroid.security,1026,NULL,0,0,64]  
I/notification_enqueue(  500): [com.kindroid.security,1020,NULL,0,Notification(pri=0 contentView=com.kindroid.security/0x7f030052 vibrate=null sound=null defaults=0x0 flags=0x2 kind=[null])]  
I/notification_cancel(  500): [com.kindroid.security,1026,NULL,0,0,64]  
I/notification_enqueue(  500): [com.kindroid.security,1020,NULL,0,Notification(pri=0 contentView=com.kindroid.security/0x7f030052 vibrate=null sound=null defaults=0x0 flags=0x2 kind=[null])]  
I/notification_cancel(  500): [com.kindroid.security,1026,NULL,0,0,64]  
octopus@octopus:~$   

以二进制形式输出日志 : 使用 adb logcat -B 命令;

octopus@octopus:~$ adb logcat -B  -t 5  
O��_�3ZS�4gps_mt3326nmea_reader_parse: line = 1218GPS get accuracy failed, fix mode:1  
^��_�3ZS�=gps_mt3326nmea_reader_addc: line = 1331the structure include nmea_cb address is 0x658cc8e8  
H��_�3ZSEGEgps_mt3326nmea_reader_addc: line = 1332nmea_cb address is 0x5d2fe279  
i���3ZS�)>ADB_SERVICEScreate_local_service_socket() name=shell:export ANDROID_LOG_TAGS="" ; exec logcat -B -t 5  
7*E*E�3ZSo�YADB_SERVICESadb: unable to open /proc/17706/oom_adj  
  1. 过滤项解析
    过滤项格式 : [:priority] , 标签:日志等级, 默认的日志过滤项是 " *:I " ;

– V : Verbose (明细);

– D : Debug (调试);

– I : Info (信息);

– W : Warn (警告);

– E : Error (错误);

– F : Fatal (严重错误);

– S : Silent(Super all output) (最高的优先级, 可能不会记载东西);

过滤指定等级日志 : 使用 adb logcat 10 *:E 命令, 显示 Error 以上级别的日志;

octopus@octopus:~$ adb logcat *:E  
  
Note: log switch off, only log_main and log_events will have logs!  
--------- beginning of /dev/log/main  
E/WifiHW  (  441): wifi_send_command : SCAN_RESULTS ; interface index=0;  
E/WifiHW  (  441): wifi_send_command : AP_SCAN 1 ; interface index=0;  
E/WifiHW  (  441): wifi_send_command : SCAN_RESULTS ; interface index=0;  
E/dalvikvm(  756): GC_CONCURRENT freed 1809K, 27% free 19489K/26695K, paused 16ms+5ms, total 109ms  
E/WifiHW  (  441): wifi_send_command : SCAN ; interface index=0;  
E/WifiHW  (  441): wifi_send_command : AP_SCAN 1 ; interface index=0;  
E/WifiHW  (  441): wifi_send_command : SCAN_RESULTS ; interface index=0;  
E/dalvikvm(  756): GC_CONCURRENT freed 1820K, 27% free 19490K/26695K, paused 16ms+3ms, total 102ms  
E/WifiHW  (  441): wifi_send_command : AP_SCAN 1 ; interface index=0;  
E/WifiHW  (  441): wifi_send_command : SCAN_RESULTS ; interface index=0;  

过滤指定标签等级日志 : 使用 adb logcat WifiHW:D *:S 命令进行过滤;

– 命令含义 : 输出10条日志, 日志是 标签为 WifiHW, 并且优先级 Debug(调试) 等级以上的级别的日志;

– 注意 *:S : 如果没有 *S 就会输出错误;

octopus@octopus:~$ adb logcat WifiHW:D *:S  
  
Note: log switch off, only log_main and log_events will have logs!  
--------- beginning of /dev/log/main  
E/WifiHW  (  441): wifi_send_command : SCAN_RESULTS ; interface index=0;  
E/WifiHW  (  441): wifi_send_command : AP_SCAN 1 ; interface index=0;  
E/WifiHW  (  441): wifi_send_command : SCAN_RESULTS ; interface index=0;  
E/WifiHW  (  441): wifi_send_command : AP_SCAN 1 ; interface index=0;  
E/WifiHW  (  441): wifi_send_command : SCAN_RESULTS ; interface index=0;  
E/WifiHW  (  441): wifi_send_command : AP_SCAN 1 ; interface index=0;  
E/WifiHW  (  441): wifi_send_command : SCAN_RESULTS ; interface index=0;  

可以同时设置多个过滤器 : 使用 adb logcat WifiHW:D dalvikvm:I *:S 命令, 输出 WifiHW 标签 的 Debug 以上级别 和 dalvikvm 标签的 Info 以上级别的日志;

octopus@octopus:~$ adb logcat WifiHW:D dalvikvm:I *:S   
  
Note: log switch off, only log_main and log_events will have logs!  
--------- beginning of /dev/log/main  
E/WifiHW  (  441): wifi_send_command : AP_SCAN 1 ; interface index=0;  
E/WifiHW  (  441): wifi_send_command : SCAN_RESULTS ; interface index=0;  
E/dalvikvm(  756): GC_CONCURRENT freed 1820K, 27% free 19490K/26695K, paused 17ms+2ms, total 110ms  
E/WifiHW  (  441): wifi_send_command : AP_SCAN 1 ; interface index=0;  
E/WifiHW  (  441): wifi_send_command : SCAN_RESULTS ; interface index=0;  
E/WifiHW  (  441): wifi_send_command : AP_SCAN 1 ; interface index=0;  
E/WifiHW  (  441): wifi_send_command : SCAN_RESULTS ; interface index=0;  
E/dalvikvm(  756): GC_CONCURRENT freed 1810K, 27% free 19489K/26695K, paused 17ms+5ms, total 108ms  
E/WifiHW  (  441): wifi_send_command : AP_SCAN 1 ; interface index=0;  
E/WifiHW  (  441): wifi_send_command : SCAN_RESULTS ; interface index=0;  
  1. 使用管道过滤日志
    (1) 过滤固定字符串
    过滤固定字符串 : 只要命令行出现的日志都可以过滤, 不管是不是标签;

– 命令 : adb logcat | grep Wifi ;

octopus@octopus:~$ adb logcat | grep Wifi  
E/WifiHW  (  441): wifi_send_command : AP_SCAN 1 ; interface index=0;  
E/WifiHW  (  441): wifi_send_command : SCAN_RESULTS ; interface index=0;  
E/WifiHW  (  441): wifi_send_command : SCAN ; interface index=0;  
E/WifiHW  (  441): wifi_send_command : AP_SCAN 1 ; interface index=0;  
E/WifiHW  (  441): wifi_send_command : SCAN_RESULTS ; interface index=0;  
E/WifiHW  (  441): wifi_send_command : AP_SCAN 1 ; interface index=0;  
E/WifiHW  (  441): wifi_send_command : SCAN_RESULTS ; interface index=0;  

在这里插入图片描述
过滤字符串忽略大小写 : adb logcat | grep -i wifi ;

在这里插入图片描述
(2) 使用正则表达式匹配
分析日志 : 该日志开头两个字符是 “V/”, 后面开始就是标签, 写一个正则表达式 “^…ActivityManager”, 就可以匹配日志中的 “V/ActivityManager” 字符串;

V/ActivityManager(  574): getTasks: max=1, flags=0, receiver=null

正则表达式过滤日志 : 使用上面的正则表达式组成命令 adb logcat | grep “^…Activity” ;

  • 1
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值