Skip to content

Commit

Permalink
v2.0.3: bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
yurijmikhalevich committed Dec 11, 2016
1 parent 571a24d commit e1004d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ exports.prepareMetaData = meta=>{
// through cycling properties and `common.clone` doesn't copies them
return {message: meta.message, name: meta.name, stack: meta.stack};
}
meta = common.clone(meta);
if (typeof meta === 'object' && meta !== null) {
makeObjectNonCircular(meta);
meta = makeObjectNonCircular(meta);
cleanFieldNames(meta);
}
meta = common.clone(meta);
return meta;
};

Expand Down Expand Up @@ -58,18 +58,22 @@ function cleanFieldNames(object) {
function makeObjectNonCircular(node, opt_parents) {
opt_parents = opt_parents || [];
opt_parents.push(node);
let copy = {};
for (let key in node) {
if (!Object.prototype.hasOwnProperty.call(node, key)) {
continue;
}
let value = node[key];
if (typeof value === 'object') {
if (opt_parents.indexOf(value) === -1) {
makeObjectNonCircular(value, opt_parents);
copy[key] = makeObjectNonCircular(value, opt_parents);
} else {
node[key] = '[Circular]';
copy[key] = '[Circular]';
}
} else {
copy[key] = value;
}
}
opt_parents.pop();
return copy;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "winston-mongodb",
"license": "MIT",
"version": "2.0.2",
"version": "2.0.3",
"description": "A MongoDB transport for winston",
"author": "Charlie Robbins <[email protected]>",
"contributors": [
Expand Down

0 comments on commit e1004d3

Please sign in to comment.