Search code examples
javascriptconsolegoogle-chrome-extensionremote-debugging

Chrome Extensions: Get Current Console to Send Up to Server


Is it possible to get the current output of the console in any form?

For example, it would be great for my debugging purposes if whenever a test failed on a user's machine, I could call something like:

console.trace()
output = console.dump()
$.post("https://<myserver>/debug/logs", { "console" : output } );

which would wrap up the current console output and send it up to a server.

In a more general sense, I would like to include a button to submit a bug report, and would like each bug report to be packaged with as much contextual data as possible.

Full Disclosure: I'm aware I could just avoid calling console.log() and instead call my own specialized logging function for storing/uploading error logs. I include the console.trace() line to motivate why this intermediate-step solution wouldn't be ideal, but ultimately the reason I don't want to do it is because I am building a general debugging module that can be used immediately in any extension (so the average developer using console.log or console.error will be able to insert one or two lines to set up remote debugging).


Solution

  • I don't think it is possible in Chrome. You can use the handy console.dir() command to see what functions are available for console. I didn't see anything that would get any text from console.

    You get the list like this:

    console.dir(console)