Timestamp and clarify debug logs

This commit is contained in:
emerson 2022-02-09 07:52:50 -05:00
parent 540fd979fc
commit fa58928ec2

View file

@ -152,14 +152,16 @@ export class IRCUser {
doSync(): void {
if (!this.isSynced()) {
console.log("not syncing, initial sync not completed");
console.log(`[${new Date().toISOString()}] ${this.homeserver}: not syncing, initial sync not completed`);
return;
}
if (this.isSyncing) {
if ((Date.now() - this.currentSyncTime) > 20000)
console.log(`Sync is lagging, current sync has been running for ${Date.now() - this.currentSyncTime} milliseconds`);
console.log(`[${new Date().toISOString()}] ${this.homeserver}: Sync is lagging, current sync has been running for ${Date.now() - this.currentSyncTime} milliseconds`);
return;
}
if (this.currentSyncTime === 0)
console.log(`[${new Date().toISOString()}] ${this.homeserver}: Synced to network!`);
this.currentSyncTime = Date.now();
this.isSyncing = true;
const endpoint = `https://${this.homeserver}/_matrix/client/v3/sync?access_token=${this.accessToken}&since=${this.nextBatch}&timeout=15000`;
@ -178,7 +180,11 @@ export class IRCUser {
}
this.isSyncing = false;
}).catch((error) => {
console.log(error);
if (error.response) {
console.log(`[${new Date().toISOString()}] Error from ${this.homeserver}: ${error.response.status} ${error.response.statusText}`)
} else {
console.log(`[${new Date().toISOString()}] Error from ${this.homeserver}: ${error}`);
}
this.isSyncing = false;
});
}