Put a value in webkit console from console.log into a variable

google-chrome, javascript, web-inspector, webkit

Solution

Here's a way to do it without wrapping `console.log` in a custom log function:

var justLogged;
var oldLog = console.log;

console.log = function () {
    oldLog.apply(console, arguments);
    justLogged = arguments;
};

console.log('test');

// if necessary, restore console.log to its original behavior when you're finished with it
console.log = oldLog;

The value of `justLogged` will be `['test']`, since you just logged it.

Problem

If there is an output in the chrome/safari webkit inspector containing an object that prints out such as: Only much more complicated with loads of nested objects (which is why a copy/paste wont do) Is there a way to put this in a variable to inspect in further and process it after its been printed on the console (its printed via `console.log`), just only after its already in the console?

Original source