From ad0c813833937518f83ee48d18ea53f27b8e13f6 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 18 Feb 2021 19:48:19 +0100 Subject: [PATCH] don't take network time into account in sync log filter --- src/logging/LogItem.js | 16 ++++++++++++++++ src/matrix/Sync.js | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/logging/LogItem.js b/src/logging/LogItem.js index 75f91fe7..197adfc6 100644 --- a/src/logging/LogItem.js +++ b/src/logging/LogItem.js @@ -44,6 +44,22 @@ export class LogItem { return null; } } + + durationWithoutType(type) { + return this.duration - this.durationOfType(type); + } + + durationOfType(type) { + if (this._values.t === type) { + return this.duration; + } else if (this._children) { + return this._children.reduce((sum, c) => { + return sum + c.durationOfType(type); + }, 0); + } else { + return 0; + } + } /** * Creates a new child item that finishes immediately diff --git a/src/matrix/Sync.js b/src/matrix/Sync.js index 378e5168..a1883642 100644 --- a/src/matrix/Sync.js +++ b/src/matrix/Sync.js @@ -96,7 +96,7 @@ export class Sync { while(this._status.get() !== SyncStatus.Stopped) { let roomStates; let sessionChanges; - let wasCatchup = this._status.get() === SyncStatus.CatchupSync; + let wasCatchupOrInitial = this._status.get() === SyncStatus.CatchupSync || this._status.get() === SyncStatus.InitialSync; await this._logger.run("sync", async log => { log.set("token", syncToken); log.set("status", this._status.get()); @@ -150,7 +150,7 @@ export class Sync { }, this._logger.level.Info, (filter, log) => { - if (log.duration >= 2000 || log.error || wasCatchup) { + if (log.durationWithoutType("network") >= 2000 || log.error || wasCatchupOrInitial) { return filter.minLevel(log.level.Detail); } else { return filter.minLevel(log.level.Info);