我的应用程序使用的外部库之一的 logcat 标记中有空格:
Log.d("Some External Library", "Debug Message");
如何在 logcat 命令中编写过滤器规范来处理空格? Eclipse 内的 Logcat 能够过滤它,但我更喜欢命令行。
我已尝试以下方法,但不起作用:
adb logcat -s "Some External Library"
adb logcat -s Some\ External\ Library
adb logcat -s Some External Library
所以我的建议是使用管道。写:
adb logcat | grep 'Some External Library'
也许其他人有其他想法。
如果您只需要调试消息,请写
adb logcat '*:D' | grep 'Some External Library'
对于更多可能的标签,请写 adb logcat --help
问题是,您无法在
adb shell
环境中使用此解决方案,因为那里的文件系统是只读的。但这个解决方案应该会给你或多或少你想要的结果。
像 adb logcat -s 'Some external Library' 或
logcat -s '"Some External Library":D'
这样的命令不起作用。