Fix a breakage in log.info(err) on a logger with no serializers.

This commit is contained in:
Trent Mick 2014-09-27 21:22:17 -07:00
parent b9f347b757
commit a5ca41a150
3 changed files with 16 additions and 2 deletions

View file

@ -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.)

View file

@ -830,7 +830,7 @@ function mkLogEmitter(minLevel) {
// `log.<level>(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]))
};

View file

@ -238,3 +238,14 @@ test('log.info(<fields>, <array>)', function (t) {
});
t.end();
});
test('log.info(<err>)', 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();
});