projects
/
squeep-logger-json-console
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fallback to json dance if structureClone fails
[squeep-logger-json-console]
/
lib
/
logger.js
diff --git
a/lib/logger.js
b/lib/logger.js
index 3f336ab4c7121d17fbeaca6eacfee45bc678c043..6cc4a2b4f30065b6d51e41de253d2267a780ee95 100644
(file)
--- a/
lib/logger.js
+++ b/
lib/logger.js
@@
-3,7
+3,7
@@
const jsonReplacers = require('./json-replacers');
const dataSanitizers = require('./data-sanitizers');
const jsonReplacers = require('./json-replacers');
const dataSanitizers = require('./data-sanitizers');
-const nop = () =>
{ /**/ }
;
+const nop = () =>
undefined
;
class Logger {
/**
class Logger {
/**
@@
-94,7
+94,11
@@
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);
+ try {
+ data = structuredClone(data);
+ } catch (e) {
+ data = JSON.parse(JSON.stringify(data, replacer));
+ }
this.sanitize(data);
}
this.sanitize(data);
}
@@
-150,7
+154,7
@@
class Logger {
while (ancestors.length > 0 && ancestors.at(-1) !== this) {
ancestors.pop();
}
while (ancestors.length > 0 && ancestors.at(-1) !== this) {
ancestors.pop();
}
- if (ancestors.includes(value)) {
// eslint-disable-line security/detect-object-injection
+ if (ancestors.includes(value)) {
return '[Circular]';
} else {
ancestors.push(value);
return '[Circular]';
} else {
ancestors.push(value);
@@
-158,7
+162,7
@@
class Logger {
}
return value;
}
return value;
- }
+ }
;
}
}
}
}