Phonegap v1.1.0, how do I access output from console.log(string)?
// provide our own console if it does not exist, huge dev aid!
if(typeof window.console == "undefined")
{
window.console = {log:function(str){window.external.Notify(str);}};
}
// output any errors to console log, created above.
window.onerror=function(e){console.log("Error ::" + e);};
console.log("Installed console ! ");
It's logging to the debug output window
console.log is defined as follows
if(typeof window.console == "undefined")
{
window.console = {
log:function(str){
if(navigator.debugConsole){
navigator.debugConsole.log(str);
}
else
{// In case log messages are received before device ready
window.external.Notify("Info:" + str);
}
}
};
}
Results of both debugConsole.log() and window.external.Notify() is Debug.WriteLine(msg) method call. So potentially you can redirect debug output to for example file and persist this information to be able debug/review this information later. No connection to VS is required to debug the problem, sometimes it could be very helpful, code example
TextWriterTraceListener[] listeners = new TextWriterTraceListener[]
{
new TextWriterTraceListener("debug.log"),
new TextWriterTraceListener(Console.Out)
};
Debug.Listeners.AddRange(listeners);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With