KyleRoss / node-lambda-log

Basic logging mechanism for Node.js Lambda Functions and other AWS services, which produces logs in JSON format for easier reading through Cloudwatch Logs.
https://lambdalog.dev
MIT License
193 stars 16 forks source link

Error name omitted from metadata #52

Closed tlvince closed 3 years ago

tlvince commented 3 years ago

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 https://github.com/KyleRoss/node-lambda-log/blob/43a32ad46d9d9a00b96fe79a5f445c5079f0071d/lib/LogMessage.js#L240 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

github-actions[bot] commented 3 years ago

:tada: This issue has been resolved in version 3.0.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: