improve error handling and logging

This commit is contained in:
Ruben van de Ven 2020-09-28 12:05:16 +02:00
parent cebfae6430
commit 27b4eea796
2 changed files with 1 additions and 19 deletions

View file

@ -15,6 +15,7 @@ const defaultHTML =
<head>
<script src="/assets/p5.js"></script>
<script src="/assets/ml5.js"></script>
<script src="/previewScripts.js"></script>
<script src="/assets/webcam.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
<meta charset="utf-8" />

View file

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