issue #131 Allow log.info(<number>) and, most importantly, don't crash on that.

This commit is contained in:
Trent Mick 2014-04-03 15:59:41 -07:00
parent a689ca171e
commit 36f7e51a65
4 changed files with 6 additions and 3 deletions

View file

@ -8,6 +8,8 @@ Known issues:
## bunyan 0.22.2 (not yet released) ## bunyan 0.22.2 (not yet released)
- #131 Allow `log.info(<number>)` and, most importantly, don't crash on that.
- Update 'mv' optional dep to latest. - Update 'mv' optional dep to latest.

View file

@ -84,7 +84,7 @@ full API is:
// This is equivalent to `log.isInfoEnabled()` or // This is equivalent to `log.isInfoEnabled()` or
// `log.isEnabledFor(INFO)` in log4j. // `log.isEnabledFor(INFO)` in log4j.
log.info('hi'); // Log a simple string message. log.info('hi'); // Log a simple string message (or number).
log.info('hi %s', bob, anotherVar); // Uses `util.format` for msg formatting. log.info('hi %s', bob, anotherVar); // Uses `util.format` for msg formatting.
log.info({foo: 'bar'}, 'hi'); log.info({foo: 'bar'}, 'hi');

View file

@ -834,7 +834,7 @@ function emitRecord(rec, line, opts, stylize) {
var s = ''; var s = '';
if (res.header) { if (res.header) {
s += res.header.trimRight(); s += res.header.trimRight();
} else if (typeof(res.headers) === 'string') { } else if (typeof (res.headers) === 'string') {
s += res.headers.trimRight(); s += res.headers.trimRight();
} else if (res.headers) { } else if (res.headers) {
if (res.statusCode) { if (res.statusCode) {

View file

@ -769,7 +769,8 @@ function mkLogEmitter(minLevel) {
} else { } else {
msgArgs = Array.prototype.slice.call(args, 1); msgArgs = Array.prototype.slice.call(args, 1);
} }
} else if (typeof (args[0]) === 'string') { } else if (typeof (args[0]) === 'string' ||
typeof (args[0]) === 'number') {
// `log.<level>(msg, ...)` // `log.<level>(msg, ...)`
fields = null; fields = null;
msgArgs = Array.prototype.slice.call(args); msgArgs = Array.prototype.slice.call(args);