From a5ca41a1501b0c48d89bbee23e5a5ea84a9658ea Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Sat, 27 Sep 2014 21:22:17 -0700 Subject: [PATCH] Fix a breakage in `log.info(err)` on a logger with no serializers. --- CHANGES.md | 5 ++++- lib/bunyan.js | 2 +- test/log.test.js | 11 +++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) 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(); +});