-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not modify Error or Date objects when logging. Fixes #610 #703
Conversation
Thank you for your contribution. The inner working of |
if (obj instanceof Error) { | ||
return obj; | ||
// With potential custom Error objects, this might not be exactly correct, | ||
// but probably close-enough for purposes of this lib. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is not going to cut it for winston
, sorry. Do this:
copy = new Error(obj.message);
Object.getOwnPropertyNames(obj).forEach(function (key) {
copy[key] = obj[key];
});
return copy;
@harriha had some cycles (no pun intended) to review the This is the last PR I'd like to land before releasing |
Cherry-picked this and made the change myself. Thank you for your contribution! |
Hey, great to see this moving forward, thanks! And sorry for that one gotcha, didn't manage to react before you got it done, thanks for pushing this forward - and looking forward for the 2.x release! |
Hi,
Ended up taking a stab on this issue, but not 100% sure if this is the best way to do it (and is this all) since I'm not that familiar with this lib - review welcome, luckily there's not much changes.
My concerns/notes:
Error
/Date
objects - probably not a real issueThe fact that these types of objects were returned as-is from
clone()
in the first place puzzles me a bit, wonder if there was something non-obvious behind that approach.In case there's something to fix, please let me know.