Add: logger
This commit is contained in:
@@ -196,4 +196,19 @@ function object_array_sort(data, key, order, fn) {
|
||||
}
|
||||
fn(data);
|
||||
}
|
||||
localStorage.removeItem("errors");
|
||||
function setLog(txt1, txt2,txt3){
|
||||
//url,statuscode,responsetext
|
||||
var text = new Date().toUTCString()
|
||||
text=text+","+txt1+","+txt2+","+escapeCsv(txt3)
|
||||
console.error(text)
|
||||
postMessage(["log", text], "*")
|
||||
}
|
||||
function escapeCsv(str) {
|
||||
if(!str){return str;}
|
||||
var result;
|
||||
result = str.replace(/\"/g, "\"\"");
|
||||
if (result.indexOf(",") >= 0) {
|
||||
result = "\"" + result + "\""
|
||||
}
|
||||
return result;
|
||||
}
|
@@ -25,6 +25,11 @@ function tl(data) {
|
||||
'Authorization': 'Bearer ' + at
|
||||
},
|
||||
}).then(function (response) {
|
||||
if (!response.ok) {
|
||||
response.text().then(function(text) {
|
||||
setLog(response.url, response.status, text);
|
||||
});
|
||||
}
|
||||
return response.json();
|
||||
}).catch(function (error) {
|
||||
console.error(error);
|
||||
@@ -199,6 +204,7 @@ function post() {
|
||||
httpreq.send(JSON.stringify(toot));
|
||||
httpreq.onreadystatechange = function() {
|
||||
if (httpreq.readyState === 4) {
|
||||
if(this.status!==200){ setLog(start, this.status, this.response); }
|
||||
$("#textarea").val("");
|
||||
}
|
||||
};
|
||||
|
@@ -63,6 +63,8 @@ onmessage = function(e) {
|
||||
ipc.send("sendMarkersComplete", null);
|
||||
} else if (e.data[0] == "copy") {
|
||||
ipc.send("copy", e.data[1]);
|
||||
} else if (e.data[0] == "log") {
|
||||
ipc.send("log", e.data[1]);
|
||||
}
|
||||
};
|
||||
//version.js
|
||||
|
Reference in New Issue
Block a user