projects
/
squeep-logger-json-console
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
fdc5534
)
fix ordering of replacing and de-cycling to work correctly in some situations
author
Justin Wind
<justin.wind+git@gmail.com>
Wed, 22 Nov 2023 17:27:28 +0000
(09:27 -0800)
committer
Justin Wind
<justin.wind+git@gmail.com>
Wed, 22 Nov 2023 17:27:28 +0000
(09:27 -0800)
lib/logger.js
patch
|
blob
|
history
diff --git
a/lib/logger.js
b/lib/logger.js
index e11810e1d312b5efa36478b418a5bdf25c27a728..3f336ab4c7121d17fbeaca6eacfee45bc678c043 100644
(file)
--- a/
lib/logger.js
+++ b/
lib/logger.js
@@
-94,7
+94,7
@@
class Logger {
if (this.sanitizationNeeded(data)) {
// Create copy of data so we are not changing anything important.
if (this.sanitizationNeeded(data)) {
// Create copy of data so we are not changing anything important.
- data = structuredClone(data
, replacer
);
+ data = structuredClone(data);
this.sanitize(data);
}
this.sanitize(data);
}
@@
-140,8
+140,13
@@
class Logger {
const ancestors = [];
const loggerReplacers = this.jsonReplacers;
return function cycleReplacer(key, value) {
const ancestors = [];
const loggerReplacers = this.jsonReplacers;
return function cycleReplacer(key, value) {
+ loggerReplacers.every((replacer) => {
+ const oldValue = value;
+ value = replacer(key, value);
+ return oldValue === value;
+ });
if (typeof value === 'object' && value !== null) {
if (typeof value === 'object' && value !== null) {
- //
this
is object where key/value came from
+ //
'this'
is object where key/value came from
while (ancestors.length > 0 && ancestors.at(-1) !== this) {
ancestors.pop();
}
while (ancestors.length > 0 && ancestors.at(-1) !== this) {
ancestors.pop();
}
@@
-152,11
+157,6
@@
class Logger {
}
}
}
}
- loggerReplacers.every((replacer) => {
- const oldValue = value;
- value = replacer(key, value);
- return oldValue === value;
- });
return value;
}
}
return value;
}
}