More logging!!!

This commit is contained in:
Christopher Cookman 2024-07-22 11:52:21 -06:00
parent db31f3f31f
commit 37dfa3d48b
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42

View file

@ -195,6 +195,12 @@ const watchFiles = () => {
tmp = funcs.makeBansTable(newContents)
// Do stuff
console.log(`IP Bans changed\nOld Length: ${Object.keys(ipBans).length}\nNew Length: ${Object.keys(tmp).length}`)
// if the number of adds or removes is over 40 ignore it
if (Object.keys(funcs.diff(ipBans, tmp).added).length > 40 || Object.keys(funcs.diff(ipBans, tmp).removed).length > 40) {
console.log("Too many changes, logging and ignoring")
fs.writeFileSync(`errors/changes-${Date.now()}.log`, JSON.stringify(funcs.diff(idBans, tmp), null, 2));
return;
}
sendMessages(funcs.diff(ipBans, tmp))
ipBans = jsonfix(tmp)
ipRaw = String(newContents)
@ -205,6 +211,12 @@ const watchFiles = () => {
// Do stuff
console.log(`ID Bans changed\nOld Length: ${Object.keys(idBans).length}\nNew Length: ${Object.keys(tmp).length}`)
console.log(JSON.stringify(funcs.diff(idBans, tmp), null, 2))
// if the number of adds or removes is over 40 ignore it
if (Object.keys(funcs.diff(idBans, tmp).added).length > 40 || Object.keys(funcs.diff(idBans, tmp).removed).length > 40) {
console.log("Too many changes, logging and ignoring")
fs.writeFileSync(`errors/changes-${Date.now()}.log`, JSON.stringify(funcs.diff(idBans, tmp), null, 2));
return;
}
sendMessages(funcs.diff(idBans, tmp))
idBans = jsonfix(tmp)
idRaw = String(newContents)