-
Notifications
You must be signed in to change notification settings - Fork 518
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1.8.3. Fix
log.info(null)
crash that resulted from #426 in v1.8.2.
Fixes #450
- Loading branch information
Showing
5 changed files
with
35 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "bunyan", | ||
"version": "1.8.2", | ||
"version": "1.8.3", | ||
"description": "a JSON logging library for node.js services", | ||
"author": "Trent Mick <[email protected]> (http://trentm.com)", | ||
"main": "./lib/bunyan.js", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -239,13 +239,33 @@ test('log.info(<fields>, <array>)', function (t) { | |
t.end(); | ||
}); | ||
|
||
test('log.info(<err>)', function (t) { | ||
var e = new Error('boom'); | ||
|
||
/* | ||
* By accident (starting with trentm/node-bunyan#85 in [email protected]), | ||
* log.info(null, ...) | ||
* was interpreted as `null` being the object of fields. It is gracefully | ||
* handled, which is good. However, had I to do it again, I would have made | ||
* that interpret `null` as the *message*, and no fields having been passed. | ||
* I think it is baked now. It would take a major bunyan rev to change it, | ||
* but I don't think it is worth it: passing `null` as the first arg isn't | ||
* really an intended way to call these Bunyan methods for either case. | ||
*/ | ||
|
||
test('log.info(null)', function (t) { | ||
names.forEach(function (lvl) { | ||
log3[lvl].call(log3, null); | ||
var rec = catcher.records[catcher.records.length - 1]; | ||
t.equal(rec.msg, '', format('log.%s msg: got %j', lvl, rec.msg)); | ||
}); | ||
t.end(); | ||
}); | ||
|
||
test('log.info(null, <msg>)', function (t) { | ||
names.forEach(function (lvl) { | ||
log3[lvl].call(log3, e); | ||
log3[lvl].call(log3, null, 'my message'); | ||
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.equal(rec.msg, 'my message', | ||
format('log.%s msg: got %j', lvl, rec.msg)); | ||
}); | ||
t.end(); | ||
}); |