reading the firebug console in javascript reading the firebug console in javascript selenium selenium

reading the firebug console in javascript


You could overwrite the console.log function to add whatever extra functionality you need.

var oldLog = console.log;var lastLog;console.log = function () {    // do whatever you need to do here: store the logs into a different variable, etc    // eg:    lastLog = arguments;    // then call the regular log command    oldLog.apply(console, arguments);};

This won't be the most bulletproof solution, since console allows printf style syntax:

console.log("%d + %d = %s", 1, 3, "four");

...but it's probably a start for you.


Don't try and override console.debug, implement a function that does console.debug plus what you need.

var debugCalls = [ ];function myDebug(errorMessage){  console.debug(errorMessage); //maintain original functionality  debugCalls[debugCalls.length]  = errorMessage;  //the previous argument to myDebug is debugCalls[debugCalls.length]  //you may also want to call an ajax function to report this error  mailError(errorMessage);}


Could you rewrite the console.log(), and append all logs to an array? Then fire up the original console.log() and repeat what it's doing to get your debug output on the console?