diff --git a/CHANGES.md b/CHANGES.md index f9817f2..3e81908 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,11 +8,14 @@ Known issues: ## bunyan 1.1.2 (not yet released) -(nothing yet) +- Fix a breakage in `log.info(err)` on a logger with no serializers. ## bunyan 1.1.1 +Note: *Bad release.* It breaks `log.info(err)` on a logger with no serializers. +Use version 1.1.2. + - [pull #168] Fix handling of `log.info(err)` to use the `log` Logger's `err` serializer if it has one, instead of always using the core Bunyan err serializer. (By Mihai Tomescu.) diff --git a/lib/bunyan.js b/lib/bunyan.js index 49100ed..6d25efa 100644 --- a/lib/bunyan.js +++ b/lib/bunyan.js @@ -830,7 +830,7 @@ function mkLogEmitter(minLevel) { // `log.(err, ...)` fields = { // Use this Logger's err serializer, if defined. - err: (log.serializers.err + err: (log.serializers && log.serializers.err ? log.serializers.err(args[0]) : Logger.stdSerializers.err(args[0])) }; diff --git a/test/log.test.js b/test/log.test.js index 5483f68..38a8996 100644 --- a/test/log.test.js +++ b/test/log.test.js @@ -238,3 +238,14 @@ test('log.info(, )', function (t) { }); t.end(); }); + +test('log.info()', function (t) { + var e = new Error('boom'); + names.forEach(function (lvl) { + log3[lvl].call(log3, e); + var rec = catcher.records[catcher.records.length - 1]; + t.equal(rec.err.message, 'boom', + format('log.%s err.message: got %j', lvl, rec.err.message)); + }); + t.end(); +});