Closed kaihendry closed 3 years ago
@kaihendry Thanks for reporting this issue. An error must be passed as the first parameter of log.error()
instead of the second, which is metadata.
const log = require("lambda-log");
try {
var milli = new Date().now();
} catch (error) {
log.error(error);
}
The metadata (meta
for short) argument only takes a plain object. Since an Error
is not a plain object, it cannot be injected into the metadata of the log message. Adding support for that would require lambda-log to recursively integrate over the meta object to find any error or error-like objects to convert to a plain object which would add too much overhead to this project.
So in order to wrap the error with some more context, what would you suggest?
log.error(error, {message: "more context"})
Or am I missing something? Thank you
What happens?
Error isn't shown with log.error
What were you expecting to happen?
error to be shown with msg context
Steps to reproduce
Any logs, output, examples?
Environment
Operating System: Archlinux Node Version: v16.9.1 Lambda Log Version: ^3.0.0