bunyan: Potentially fix logging error properties
All checks were successful
continuous-integration/appveyor/branch AppVeyor build succeeded

This commit is contained in:
Jonatan Nilsson 2022-10-17 08:49:57 +00:00
parent e28bfc0d1c
commit 035af486a2
2 changed files with 9 additions and 3 deletions

View file

@ -771,13 +771,19 @@ Logger.prototype._emit = function (rec, noemit) {
function mkRecord(log, minLevel, args) { function mkRecord(log, minLevel, args) {
var excludeFields, fields, msgArgs; var excludeFields, fields, msgArgs;
if (args[0] instanceof Error) { if (args[0] instanceof Error) {
var err = args[0];
// `log.<level>(err, ...)` // `log.<level>(err, ...)`
fields = { fields = {
// Use this Logger's err serializer, if defined. // Use this Logger's err serializer, if defined.
err: (log.serializers && log.serializers.err err: (log.serializers && log.serializers.err
? log.serializers.err(args[0]) ? log.serializers.err(err)
: Logger.stdSerializers.err(args[0])) : Logger.stdSerializers.err(err))
}; };
for (const key in err) {
if (Object.prototype.hasOwnProperty.call(err, key)) {
fields[key] = err[key];
}
}
excludeFields = {err: true}; excludeFields = {err: true};
if (args.length === 1) { if (args.length === 1) {
msgArgs = [fields.err.message]; msgArgs = [fields.err.message];

View file

@ -1,6 +1,6 @@
{ {
"name": "bunyan-lite", "name": "bunyan-lite",
"version": "1.2.0", "version": "1.2.1",
"description": "a lite version of bunyan, a JSON logging library for node.js services with zero dependency", "description": "a lite version of bunyan, a JSON logging library for node.js services with zero dependency",
"author": "Jonatan Nilsson <jonatan@nilsson.is> (https://nfp.is)", "author": "Jonatan Nilsson <jonatan@nilsson.is> (https://nfp.is)",
"main": "./lib/bunyan.mjs", "main": "./lib/bunyan.mjs",