fix FileSystemInfo logging when multiple different types of invalidation occur

This commit is contained in:
Tobias Koppers 2019-11-14 17:28:10 +01:00
parent c124637646
commit 6172b61938
1 changed files with 16 additions and 9 deletions

View File

@ -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;