Skip to content

Error name omitted from metadata #52

Description

@tlvince

What happens?

The name of Error objects is not included in the log metadata. It is omitted as it's a non-enumerable property on Error.prototype, not the instance and so

if(Object.prototype.hasOwnProperty.call(err, key)) {
will always return false.

What were you expecting to happen?

The Error name to be included in metadata

Steps to reproduce

const log = require('lambda-log')
const error = new Error('foo')
log.error('bar', { error })
{
  "_logLevel": "error",
  "msg": "bar",
  "error": {
    "message": "foo",
    "stack": "Error: foo\n    at Object.<anonymous> (/tmp/index.js:436:13)\n    at Module._compile (internal/modules/cjs/loader.js:1072:14)\n    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)\n    at Module.load (internal/modules/cjs/loader.js:937:32)\n    at Function.Module._load (internal/modules/cjs/loader.js:778:12)\n    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)\n    at internal/main/run_main_module.js:17:47"
  },
  "_tags": []
}

Environment

Operating System: Linux
Node Version: 14.17.5
Lambda Log Version: 3.0.0

Activity

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

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions