, console.log
, , oldLog.apply(this,arguments);
. , , console.error
, , , , .
, ,
(function () {
function origin() {
try {
throw Error('');
} catch (err) {
return err.stack.split('\n').slice(-1)[0];
}
}
function send_stuff() { }
var oldLog = console.log;
console.log = function (msg) {
oldLog.call(this, ...arguments, origin());
send_stuff(Array.prototype.slice.call(arguments).join());
};
})();
console.log("test");
console.log("Hello %s", "Bob");
console.log("Here is an object %o", {
stuff: "thing"
});