improve error handling and logging

This commit is contained in:
Ruben van de Ven 2020-09-28 11:27:03 +02:00
parent aa2d324cab
commit a6594f142b

View file

@ -458,16 +458,18 @@ if (event.reason && event.reason.message && event.reason.stack){
(function(){ (function(){
const oldLog = console.log; const oldLog = console.log;
console.log = function () { console.log = function () {
oldLog.apply(console, arguments);
const err = new Error(); const err = new Error();
const logSrc = err.stack.split("\n")[1]; const logSrc = err.stack.split("\n")[1];
const args = arguments.map((a) => ""+a); // to string
window.parent.postMessage([{ window.parent.postMessage([{
log: [{ log: [{
method: 'log', method: 'log',
data: arguments, data: args,
id: Date.now().toString() id: Date.now().toString()
}], }],
source: logSrc source: logSrc
}], '*'); }], '*');
oldLog.apply(console, arguments);
}; };
})(); })();