Add: logger

This commit is contained in:
cutls
2019-10-31 00:30:26 +09:00
parent 9f9e4d6d6e
commit 4f7eb88a13
34 changed files with 910 additions and 311 deletions

View File

@@ -60,7 +60,12 @@ function additional(acct_id, tlid) {
},
//body: JSON.stringify({})
}).then(function (response) {
return response.json();
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -88,6 +93,7 @@ function additional(acct_id, tlid) {
if (this.readyState === 4 && this.status === 200) {
if (this.response) {
var json = this.response;
if(this.status!==200){ setLog(start, this.status, this.response); }
var emojis = json.emojis;
for (i = 0; i < emojis.length; i++) {
var emojie = emojis[i];
@@ -144,7 +150,12 @@ function additionalIndv(tlid, acct_id, id) {
},
//body: JSON.stringify({})
}).then(function (response) {
return response.json();
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -168,7 +179,12 @@ function additionalIndv(tlid, acct_id, id) {
},
//body: JSON.stringify({})
}).then(function (response) {
return response.json();
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
console.error(error);

View File

@@ -35,6 +35,11 @@ function details(id, acct_id, tlid, mode) {
}
fetch(start, i).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
@@ -131,6 +136,11 @@ function replyTL(id, acct_id) {
return false
}
fetch(start, i).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
@@ -183,6 +193,11 @@ function getContext(id, acct_id) {
}
}
fetch(start, i).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
@@ -241,7 +256,12 @@ function beforeToot(id, acct_id, domain) {
untilID: id
})
}).then(function (response) {
return response.json();
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -259,7 +279,12 @@ function beforeToot(id, acct_id, domain) {
'content-type': 'application/json',
},
}).then(function (response) {
return response.json();
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -291,7 +316,12 @@ function userToot(id, acct_id, user) {
userId: user
})
}).then(function (response) {
return response.json();
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -309,7 +339,12 @@ function userToot(id, acct_id, user) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
return response.json();
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -336,6 +371,11 @@ function afterToot(id, acct_id, domain) {
'content-type': 'application/json',
},
}).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
@@ -361,6 +401,11 @@ function afterUserToot(id, acct_id, user) {
'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) {
todo(error);
@@ -386,6 +431,11 @@ function afterFTLToot(id, acct_id, domain) {
'content-type': 'application/json',
},
}).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
@@ -413,6 +463,11 @@ function faved(id, acct_id) {
'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) {
todo(error);
@@ -440,6 +495,11 @@ function rted(id, acct_id) {
'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) {
todo(error);
@@ -500,6 +560,11 @@ function trans(tar, to) {
fetch(exec, {
method: 'GET',
}).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
@@ -528,6 +593,11 @@ function detEx(url, acct_id) {
'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) {
todo(error);

View File

@@ -51,7 +51,12 @@ function directory(isMore) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
return response.json();
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
//todo(error);
console.error(error);

View File

@@ -11,6 +11,11 @@ function dm(acct_id, tlid, type, delc, voice) {
'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) {
todo(error);
@@ -43,6 +48,11 @@ function dmmore(tlid) {
'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) {
todo(error);

View File

@@ -121,6 +121,11 @@ function filter() {
'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) {
todo(error);
@@ -199,6 +204,7 @@ function makeNewFilter() {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); }
filter();
filterUpdate(acct_id)
$("#filter-add-word").val("");
@@ -239,6 +245,11 @@ function filterEdit(id, acct_id) {
'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) {
todo(error);
@@ -282,6 +293,7 @@ function filterDel(id, acct_id) {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); }
filter();
filterUpdate(acct_id)
}
@@ -299,7 +311,12 @@ function getFilter(acct_id) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
return response.json();
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -342,6 +359,11 @@ function filterUpdate(acct_id) {
'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) {
todo(error);

View File

@@ -21,7 +21,12 @@ function list() {
i: at
}),
}).then(function (response) {
return response.json();
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -47,7 +52,12 @@ function list() {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
return response.json();
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -85,6 +95,7 @@ function makeNewList() {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); }
list();
$("#list-add").val("")
}
@@ -102,6 +113,7 @@ function makeNewList() {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); }
list();
$("#list-add").val("")
}
@@ -123,6 +135,11 @@ function listUser(id, acct_id) {
'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) {
todo(error);
@@ -153,7 +170,12 @@ function hisList(user, acct_id) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
return response.json();
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -178,7 +200,12 @@ function hisList(user, acct_id) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
return response.json();
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -203,7 +230,12 @@ function hisList(user, acct_id) {
i: at
}),
}).then(function (response) {
return response.json();
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -249,6 +281,7 @@ function listAdd(id, user, acct_id) {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); }
hisList(user, acct_id)
}
}
@@ -280,6 +313,7 @@ function listRemove(id, user, acct_id) {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); }
hisList(user, acct_id)
}
}

View File

@@ -14,6 +14,11 @@ function mixtl(acct_id, tlid, type, delc, voice) {
'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) {
todo(error);
@@ -27,7 +32,12 @@ function mixtl(acct_id, tlid, type, delc, voice) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
return response.json();
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -267,6 +277,11 @@ function mixmore(tlid, type) {
'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) {
todo(error);
@@ -280,7 +295,12 @@ function mixmore(tlid, type) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
return response.json();
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
console.error(error);

View File

@@ -43,6 +43,7 @@ function notfColumn(acct_id, tlid, sys) {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); }
var max_id = httpreq.getResponseHeader("link");
if (max_id) {
max_id = max_id.match(/[?&]{1}max_id=([0-9]+)/)[1]
@@ -152,6 +153,11 @@ function notfCommon(acct_id, tlid, sys) {
}
fetch(start, i).then(function (response) {
console.log("header to get param:" + response.headers.get('link'));
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
@@ -317,6 +323,7 @@ function notfmore(tlid) {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); }
console.log(["More notifications on " + tlid, json]);
var max_id = httpreq.getResponseHeader("link").match(/[?&]{1}max_id=([0-9]+)/)[1];
if (json[0]) {

View File

@@ -15,6 +15,11 @@ function mixtl(acct_id, tlid) {
'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) {
todo(error);
@@ -38,7 +43,12 @@ function mixtl(acct_id, tlid) {
'Authorization': 'Bearer ' + at
},
}).then(function(response) {
return response.json();
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function(error) {
todo(error);
console.error(error);
@@ -193,6 +203,11 @@ function mixmore(tlid) {
'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) {
todo(error);
@@ -211,7 +226,12 @@ function mixmore(tlid) {
'Authorization': 'Bearer ' + at
},
}).then(function(response) {
return response.json();
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function(error) {
todo(error);
console.error(error);

View File

@@ -114,6 +114,7 @@ function voteMastodonrefresh(acct_id, id) {
httpreqd.send();
httpreqd.onreadystatechange = function () {
if (httpreqd.readyState == 4) {
if(this.status!==200){ setLog(start, this.status, this.response); }
var json = httpreqd.response;
console.log(["Refresh vote", json]);
if (!json) {

View File

@@ -46,6 +46,11 @@ function src(mode, offset) {
'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) {
src("v1")
@@ -110,6 +115,11 @@ function tootsearch(tlid, q) {
'content-type': 'application/json'
},
}).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
@@ -149,6 +159,11 @@ function moreTs(tlid, q) {
'content-type': 'application/json'
},
}).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
@@ -223,6 +238,11 @@ function trend() {
'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) {
//todo(error);

View File

@@ -87,7 +87,12 @@ function trendTag() {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
return response.json();
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -143,6 +148,11 @@ function tagFeature(name, acct_id){
name: name
})
}).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
return false;

View File

@@ -128,6 +128,11 @@ function tl(type, data, acct_id, tlid, delc, voice, mode) {
console.log(["Try to get timeline of " + tlid, start])
fetch(start, i).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
@@ -438,7 +443,12 @@ function moreload(type, tlid) {
};
}
fetch(start, i).then(function (response) {
return response.json();
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -551,7 +561,12 @@ function tlDiff(type, data, acct_id, tlid, delc, voice, mode) {
fetch(start, i).then(function (response) {
return response.json();
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -897,6 +912,11 @@ function getMarker(tlid, type, acct_id) {
'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) {
$("#unread_" + tlid).attr("title", lang.lang_layout_unread + ":" + lang.lang_nothing)
@@ -940,6 +960,11 @@ function showUnread(tlid, type, acct_id) {
'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) {
todo(error);
@@ -991,6 +1016,11 @@ function ueload(tlid) {
'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) {
todo(error);
@@ -1062,6 +1092,7 @@ function asRead(callback) {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response
if(this.status!==200){ setLog(start, this.status, this.response); }
console.log(json)
ct++
if (ct == obl && callback) {