console.log in phonegap

39 views
Skip to first unread message

Pete

unread,
Jul 26, 2016, 10:03:11 AM7/26/16
to phonegap
Boy, wouldn't it be nice to have... just console.log it and have it appear on the page...

Here it is... it's a rudimentary hijacking of console that uses jquery and a #debug div but you can use console.log to output text, numbers, bools and multidimensional arrays to a scrollable div on your phonegap pages.


StefDelDestino

unread,
Jul 27, 2016, 11:34:13 AM7/27/16
to phonegap
Thanks. Sounds good.

You know that you can access the console.log from your computer? for example: http://phonegap-tips.com/articles/debugging-ios-phonegap-apps-with-safaris-web-inspector.html

Phil Petree

unread,
Jul 27, 2016, 3:04:19 PM7/27/16
to phon...@googlegroups.com
When I want to take my mobile phonegap app out into the field and test it, especially geolocating functionality, I find it a bit cumbersome to stay tethered to my laptop... and walking around with both devices while I test requires more dexterity than I can manage. ;-)



--
-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com
---
You received this message because you are subscribed to a topic in the Google Groups "phonegap" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/phonegap/cCTJBc6VT8M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to phonegap+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kerri Shotts

unread,
Jul 27, 2016, 6:16:28 PM7/27/16
to phonegap
You mean you haven't figured out how to use telekinesis yet? ;-)

Phil.petree

unread,
Jul 27, 2016, 6:55:05 PM7/27/16
to phon...@googlegroups.com
Well, I have, I can do something similar to a Vulcan Mind Meld with my devices and my bugs magically disappear but I thought I'd do this for my human compatriots, especially knowing all their "shortcomings."

Sent from my iPhone

Kerri Shotts

unread,
Jul 28, 2016, 11:50:43 AM7/28/16
to phonegap
Wow, I wish I had that particular gift. My gift is making bugs magically appear at inopportune moments! ;-) Like this morning I had to deal with a double-panicked Mac that would only start via safe mode... Good thing I had my telekinesis in check; it might have ended up on the other side of a wall, in pieces! 

I've done something similar in my apps as well, although they didn't capture console.log (the code just used a logger instance). Furthermore, if a critical error occurs while the app is in production, the app can send those errors via email to the administrative staff so they can figure out if they (or the end user) borked something or not. ;-) One does have to be careful in that case what one logs (and how much), but it makes debugging issues in production so much easier. That said, the output is a whole lot uglier (JSON.stringify, really) than the formatting you're doing in your code.


On Wednesday, July 27, 2016 at 5:55:05 PM UTC-5, Pete wrote:
Well, I have, I can do something similar to a Vulcan Mind Meld with my devices and my bugs magically disappear but I thought I'd do this for my human compatriots, especially knowing all their "shortcomings."
...

Phil Petree

unread,
Jul 28, 2016, 12:32:09 PM7/28/16
to phon...@googlegroups.com
I decided to hijack console.log because so many devs write to it while testing the html and JavaScript in a browser and before putting it in an app and, as we all know, once it's in the app it misbehaves for a litany of unforeseen reasons.  More times than not all those console.logs are still in the code.  Also, stringify() can create some confusing output for newbies dealing with multidimensional arrays.

I've had a few requests to inject the #debug div into the html but I like having the control of putting it where I want it. Also had a request to foreach() all of the console.log arguments... Maybe after these two projects on my plate are done.

I do something similar to your logger but I store it in a table and Ajax it to my server when I have a wifi connection.

Sent from my iPad
--
Reply all
Reply to author
Forward
0 new messages