mirror of
https://git.sr.ht/~emerson/reflectionircd
synced 2025-08-05 16:59:10 +00:00
Timestamp and clarify debug logs
This commit is contained in:
parent
540fd979fc
commit
fa58928ec2
1 changed files with 9 additions and 3 deletions
|
@ -152,14 +152,16 @@ export class IRCUser {
|
||||||
|
|
||||||
doSync(): void {
|
doSync(): void {
|
||||||
if (!this.isSynced()) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
if (this.isSyncing) {
|
if (this.isSyncing) {
|
||||||
if ((Date.now() - this.currentSyncTime) > 20000)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
if (this.currentSyncTime === 0)
|
||||||
|
console.log(`[${new Date().toISOString()}] ${this.homeserver}: Synced to network!`);
|
||||||
this.currentSyncTime = Date.now();
|
this.currentSyncTime = Date.now();
|
||||||
this.isSyncing = true;
|
this.isSyncing = true;
|
||||||
const endpoint = `https://${this.homeserver}/_matrix/client/v3/sync?access_token=${this.accessToken}&since=${this.nextBatch}&timeout=15000`;
|
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;
|
this.isSyncing = false;
|
||||||
}).catch((error) => {
|
}).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;
|
this.isSyncing = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue