Skip to content

Commit

Permalink
[fix] Ensure that logger.log("info", undefined) does not throw. Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Nov 3, 2015
1 parent 795cdd9 commit 1f16861
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/winston/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Logger.prototype.log = function (level) {
// logger.info('No interpolation symbols', 'ok', 'why', { meta: 'is-this' });
//
var metaType = Object.prototype.toString.call(args[args.length - 1]),
fmtMatch = args[0].match && args[0].match(formatRegExp),
fmtMatch = args[0] && args[0].match && args[0].match(formatRegExp),
isFormat = fmtMatch && fmtMatch.length,
validMeta = !isFormat
? metaType === '[object Object]' || metaType === '[object Error]' || metaType === '[object Array]'
Expand Down
3 changes: 3 additions & 0 deletions test/logger-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ vows.describe('winton/logger').addBatch({
]
}),
"the log() method": {
"when passed undefined should not throw": function (logger) {
assert.doesNotThrow(function () { logger.log('info', undefined) });
},
"when passed an Error object as meta": {
topic: function (logger) {
logger.once('logging', this.callback);
Expand Down

0 comments on commit 1f16861

Please sign in to comment.