From 6172b6193806050b8c0a441bb7d6380b111fecd2 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 14 Nov 2019 17:28:10 +0100 Subject: [PATCH] fix FileSystemInfo logging when multiple different types of invalidation occur --- lib/FileSystemInfo.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/FileSystemInfo.js b/lib/FileSystemInfo.js index 08d00a84e..daca10817 100644 --- a/lib/FileSystemInfo.js +++ b/lib/FileSystemInfo.js @@ -255,10 +255,11 @@ class FileSystemInfo { ); } - _log(path, reason) { - if (this._loggedPaths.has(path)) return; - this._loggedPaths.add(path); - this.logger.debug(`${path} invalidated because ${reason}`); + _log(path, reason, ...args) { + const key = path + reason; + if (this._loggedPaths.has(key)) return; + this._loggedPaths.add(key); + this.logger.debug(`${path} invalidated because ${reason}`, ...args); if (--this._remainingLogs === 0) { this.logger.debug( "Logging limit has been reached and no futher logging will be emitted by FileSystemInfo" @@ -1013,7 +1014,7 @@ class FileSystemInfo { }; const invalidWithError = (path, err) => { if (this._remainingLogs > 0) { - this._log(path, `error occured: ${err}`); + this._log(path, `error occured: %s`, err); } invalid(); }; @@ -1035,7 +1036,7 @@ class FileSystemInfo { if (current !== snap) { // If hash differ it's invalid if (this._remainingLogs > 0) { - this._log(path, `hashes differ (${current} != ${snap})`); + this._log(path, `hashes differ (%s != %s)`, current, snap); } return false; } @@ -1097,7 +1098,9 @@ class FileSystemInfo { if (this._remainingLogs > 0) { this._log( path, - `it may have changed (${current.safeTime}) after the start time of the snapshot (${startTime})` + `it may have changed (%d) after the start time of the snapshot (%d)`, + current.safeTime, + startTime ); } return false; @@ -1124,7 +1127,9 @@ class FileSystemInfo { if (this._remainingLogs > 0) { this._log( path, - `timestamps differ (${current.timestamp} != ${snap.timestamp})` + `timestamps differ (%d != %d)`, + current.timestamp, + snap.timestamp ); } return false; @@ -1138,7 +1143,9 @@ class FileSystemInfo { if (this._remainingLogs > 0) { this._log( path, - `timestamps hashes differ (${current.timestampHash} != ${snap.timestampHash})` + `timestamps hashes differ (%s != %s)`, + current.timestampHash, + snap.timestampHash ); } return false;