通过 logcat 在 Android 上调试 WebView (Ionic) 应用程序 [英] Debugging a WebView (Ionic) app on Android via logcat

查看:42
本文介绍了通过 logcat 在 Android 上调试 WebView (Ionic) 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于这个主题有几个问题,但似乎没有一个能解决我遇到的特定问题.

There are several questions about the subject, however not one of them seems to address the particular problem I'm having.

我正在使用 Cordova/Ionic 开发应用程序,并使用 adb logcat CordovaLog:D *:S 打印我使用 console.log() 输出的调试信息> 一直工作得很好,直到有一些更新.现在我似乎无法弄清楚如何正确过滤 logcat 的输出,所以我只能从我的应用程序中获取调试信息.

I'm developing an app with Cordova/Ionic, and printing debugging info I was outputting with console.log() by using adb logcat CordovaLog:D *:S was working just fine until some updates. Now I can't seem to figure out how to properly filter logcat's output so I could only get the debugging info from my app.

日志本身有效.如果我没有设置过滤器并将输出重定向到一个文件,我可以在所有其他调试消息中看到我的调试信息,它看起来像这样:

Logging itself works. If I set no filters and redirect output to a file, I can see my debugging info among all the other debug messages, and it looks like this:

I/Web Console: Event triggered: device.ready:1

登录屏幕也可以,但速度约为每秒 100 行.我至少尝试了以下方法来过滤输出:

Logging to screen also works, but at a rate of approximately 100 lines per second. I've tried at least the following to filter output:

adb logcat -s "Web Console"
adb logcat "Web Console":V
adb logcat "Web Console":*
adb logcat -s Web
adb logcat Web:V
adb logcat "myApp":V
adb logcat myApp:V
adb logcat -s myApp

... 可能还有其他我已经忘记了.他们要么完全不打印,要么完全来自系统服务.

... and probably others I've already forgotten. They either print absolutely nothing, or absolutely everything from the system services.

我在 Windows 上,所以我不能 grep,我正在调试的设备运行的是 Android 4.2.2,所以我不能使用 GapDebug,它似乎也没有可以通过 Chrome 中的 chrome://inspect 访问设备的日志.

I'm on Windows so I can't grep, and the device I'm debugging on is running Android 4.2.2 so I can't use GapDebug, and neither does it seem to be possible to access the device's log via chrome://inspect in Chrome.

我真的,真的很想了解过滤 logcat 的输出是如何工作的.我不愿意将所有内容都记录到一个文件中,然后再切换.

I really, really would like to understand how filtering logcat's output works. I'm not willing to log everything to a file and then shift through that.

推荐答案

logcat 似乎无法正确解析带有空格的标签名称.所以我建议在设备上使用 grep :

It seems that logcat can not properly parse tag names with whitespaces. So instead I suggest using grep on the device:

adb shell "logcat | grep 'Web Console'"

这篇关于通过 logcat 在 Android 上调试 WebView (Ionic) 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆