Added file logging

This commit is contained in:
La Programmatrice Verde
2025-08-18 16:54:32 +02:00
parent 67df0ea9f6
commit 53f732baa6
6 changed files with 43 additions and 21 deletions

View File

@@ -21,7 +21,7 @@ async function TokenRenew() {
await deleteToken(tokenID);
shared.eventEmitter.emit("tokenRenewalEnd");
} catch (error) {
console.error(`[${shared.now}] Errore nel rinnovo del token: ${error}`);
Log(`[${shared.now}] Errore nel rinnovo del token: ${error}`);
}
}, day - hour);
}
@@ -33,7 +33,7 @@ async function getUserID() {
Authorization: `Token ${shared.getToken()}`,
},
});
console.log(`[${shared.now}] UserID: ${response.data.id}`);
Log(`[${shared.now}] UserID: ${response.data.id}`);
return response.data.id;
}
@@ -46,7 +46,7 @@ async function deleteToken(tokenID) {
},
}
);
console.log(`[${shared.now}] Token con ID ${tokenID} cancellato con successo`);
Log(`[${shared.now}] Token con ID ${tokenID} cancellato con successo`);
}
async function getCurrentTokenID() {
@@ -63,7 +63,7 @@ async function getCurrentTokenID() {
const token = response.data.find((t) => t.name === "Uptime Kuma");
if (!token) throw new Error("Token 'Uptime Kuma' non trovato");
console.log(`[${shared.now}] CurrentTokenID: ${token.id}`);
Log(`[${shared.now}] CurrentTokenID: ${token.id}`);
return token.id;
}
@@ -82,7 +82,7 @@ async function getNewToken() {
},
}
);
console.log(`[${shared.now}] Nuovo token creato: ${response.data.plain_token}`);
Log(`[${shared.now}] Nuovo token creato: ${response.data.plain_token}`);
return response.data.plain_token;
}