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
1 changed files with 4 additions and 2 deletions

View File

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