Compare commits
1 Commits
developmen
...
perf-test-
Author | SHA1 | Date |
---|---|---|
Will Toozs | 482e4aa2ee |
|
@ -3,6 +3,8 @@
|
|||
|
||||
const os = require('os');
|
||||
const safeJSONStringify = require('safe-json-stringify');
|
||||
var stringify = require('fast-json-stable-stringify');
|
||||
|
||||
/*
|
||||
* This function safely stringifies JSON. If an exception occcurs (due to
|
||||
* circular references, exceptions thrown from object getters etc.), the module
|
||||
|
@ -14,7 +16,7 @@ const safeJSONStringify = require('safe-json-stringify');
|
|||
function safeStringify(obj) {
|
||||
let str;
|
||||
try {
|
||||
str = JSON.stringify(obj);
|
||||
str = stringify(obj);
|
||||
} catch (e) {
|
||||
// fallback to remove circular object references or other exceptions
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
|
@ -69,8 +71,9 @@ class SimpleLogger {
|
|||
logFields.hostname = this.hostname;
|
||||
logFields.pid = process.pid;
|
||||
|
||||
const safeString = safeStringify(logFields);
|
||||
this.streams.forEach(s => s.stream
|
||||
.write(`${safeStringify(logFields)}\n`));
|
||||
.write(`${safeString}\n`));
|
||||
}
|
||||
|
||||
info(fields, message) {
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
},
|
||||
"homepage": "https://github.com/scality/werelogs#readme",
|
||||
"dependencies": {
|
||||
"fast-json-stable-stringify": "^2.1.0",
|
||||
"safe-json-stringify": "^1.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -1064,7 +1064,7 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
|
|||
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
|
||||
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==
|
||||
|
||||
fast-json-stable-stringify@^2.0.0:
|
||||
fast-json-stable-stringify@^2.0.0, fast-json-stable-stringify@^2.1.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633"
|
||||
integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==
|
||||
|
|
Loading…
Reference in New Issue