Skip to content
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

common.log mutates an Error object passed as meta #723

Closed
eddieajau opened this issue Oct 12, 2015 · 2 comments
Closed

common.log mutates an Error object passed as meta #723

eddieajau opened this issue Oct 12, 2015 · 2 comments

Comments

@eddieajau
Copy link

In common.js there is the following code:

    output         = exports.clone(meta) || {};
    output.level   = options.level;
    output.message = options.message.stripColors;

But in exports.clone of the same file, you have:

exports.clone = function (obj) {
  //
  // We only need to clone reference types (Object)
  //
  if (obj instanceof Error) {
    return obj;
  }

If an error is passed as meta, the error message is unexpectedly mutated by the log call:

var error = new Error('this is the real error');
console.log(error.message); // -> this is the real error
logger.error('Func.name error', error);
console.log(error.message); // -> Func.name error

If you can let me know how you want that resolved, I'm happy to do the PR and tests.

@harriha
Copy link
Contributor

harriha commented Oct 21, 2015

This seems to be a duplicate of #610, and a (unmerged) fix is available in #703

@indexzero
Copy link
Member

Yes. This is a duplicate of #610. Good catch @harriha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants