diff --git a/lib/winston/logger.js b/lib/winston/logger.js index 130a8aba1..97fba6428 100755 --- a/lib/winston/logger.js +++ b/lib/winston/logger.js @@ -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]' diff --git a/test/logger-test.js b/test/logger-test.js index bc3773441..d85f7be4d 100755 --- a/test/logger-test.js +++ b/test/logger-test.js @@ -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);