Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
920 views
in Technique[技术] by (71.8m points)

cordova - Debugging a WebView (Ionic) app on Android via logcat

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

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

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.

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.

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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'"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...