How to display console.log() output in PhoneGap app using Eclipse and HTC Desire HD?
Asked Answered
C

4

28

I am developing PhoneGap webapp where I use some javascript, and sometimes I need to see console.log() output. I can easily see it when running in Chrome, it also works fine, when running this app in Android emulator - output of console.log() shows up in Eclipse LogCat window. But when I run this app on my HTC Desire HD, LogCat just shows some Android-specific output, but nothing coming from my webapp.

Anybody has idea how to display console.log() output from PhoneGap-app running on HTC Desire HD ?

Caller answered 1/5, 2011 at 8:12 Comment(0)
T
19

See the PhoneGap mail list thread. Also, two stackoverflow threads here and here.

It seems that console.log is disabled on HTC devices running Android 2.2.

The best workaround I've found is to use weinre, which intercepts the console.log to show the output in its desktop browser console.

Update: PhoneGap 1.3.0 now supports console.log directly to LogCat from the HTC Evo without any workarounds. (The same program doesn't work with PhoneGap 1.1.0)

Tether answered 1/5, 2011 at 15:20 Comment(2)
The 1.3.0 workaround in the guts of PhoneGap is to change DroidGap.init to call: // Set the nav dump for HTC settings.setNavDump(true);Tether
A lot of data seems to get dumped to the LogCat, so I'd suggest adding a filter, and filter by the Log Tag, "CordovaLog". Then from your PhoneGap Javascript you can simply call console.log("Message"); to output a message to the log.Vivianna
P
32

Another workaround is to use console.log() jsconsole.com

Prescott answered 6/5, 2011 at 10:22 Comment(1)
WARNING: The console log approach doesn't work on all devices. Especially some HTC phones with 2.3 versions.Lyndsaylyndsey
T
19

See the PhoneGap mail list thread. Also, two stackoverflow threads here and here.

It seems that console.log is disabled on HTC devices running Android 2.2.

The best workaround I've found is to use weinre, which intercepts the console.log to show the output in its desktop browser console.

Update: PhoneGap 1.3.0 now supports console.log directly to LogCat from the HTC Evo without any workarounds. (The same program doesn't work with PhoneGap 1.1.0)

Tether answered 1/5, 2011 at 15:20 Comment(2)
The 1.3.0 workaround in the guts of PhoneGap is to change DroidGap.init to call: // Set the nav dump for HTC settings.setNavDump(true);Tether
A lot of data seems to get dumped to the LogCat, so I'd suggest adding a filter, and filter by the Log Tag, "CordovaLog". Then from your PhoneGap Javascript you can simply call console.log("Message"); to output a message to the log.Vivianna
A
0

I've found that console.error gets higher priority than console.log , and appears in the adb logcat output for both emulator devices and real devices connected via USB.

Albertoalberts answered 23/4, 2014 at 12:7 Comment(0)
S
-2

Try this filter:

adb logcat PhoneGapLog:V *:S

It will only show console.log and phonegap specific output.

Smutchy answered 1/5, 2011 at 11:53 Comment(1)
There is nothing from PhoneGap in the log, so the filtering won't help anything..Caller

© 2022 - 2024 — McMap. All rights reserved.