ich eine einfache Cross-Browser-Bibliothek für diese, die so genannte console.history
schrieb. Es ist auf GitHub verfügbar: https://git.io/console
Was im Grunde die Bibliothek tut, ist alle Anrufe console.[log/warn/error/debug/info]
fangen und speichern sie in der console.history
Array. Als Bonus wird auch eine vollständige Stapelverfolgung hinzugefügt.
Testdatei test.js
enthält:
function outer() {
inner();
}
function inner() {
var array = [1,2,3];
var object = {"foo": "bar", "key": "value"};
console.warn("Something went wrong, but we're okay!", array, object);
}
outer();
Der Eintrag zu console.history
wird:
{
"type": "warn",
"timestamp": "Thu, 01 Sep 2016 15:38:28 GMT",
"arguments": {
"0": "Something went wrong, but we're okay!",
"1": [1, 2, 3],
"2": {
"foo": "bar",
"key": "value"
}
},
"stack": {
"0": "at inner (http://localhost:1337/test/test.js:6:11)",
"1": "at outer (http://localhost:1337/test/test.js:2:3)",
"2": "at http://localhost:1337/test/test.js:9:1"
}
}
http://www.whathaveyoutried.com/? Soll das auf einer Website oder als Browser-Plugin laufen? Was ist dein Zielbrowser? Bitte fügen Sie diese Informationen zu Ihrer Frage/Tags hinzu. – rekire
Geben Sie eine detaillierte Erklärung, was Sie zu tun versuchen. Nur dann können wir Ihnen helfen. –