From adeb7142438de480e96baf0b17fd438a131bc3a1 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Fri, 17 Apr 2015 08:31:12 +1000 Subject: [PATCH] made calling logger.log safe if level is not provided as first argument (github issue #279) --- examples/example.js | 2 ++ lib/logger.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/example.js b/examples/example.js index 25c9544..d304cc4 100644 --- a/examples/example.js +++ b/examples/example.js @@ -35,11 +35,13 @@ logger.setLevel('ERROR'); //console logging methods have been replaced with log4js ones. //so this will get coloured output on console, and appear in cheese.log console.error("AAArgh! Something went wrong", { some: "otherObject", useful_for: "debug purposes" }); +console.log("This should appear as info output"); //these will not appear (logging level beneath error) logger.trace('Entering cheese testing'); logger.debug('Got cheese.'); logger.info('Cheese is Gouda.'); +logger.log('Something funny about cheese.'); logger.warn('Cheese is quite smelly.'); //these end up on the console and in cheese.log logger.error('Cheese %s is too ripe!', "gouda"); diff --git a/lib/logger.js b/lib/logger.js index 67bb35d..49907ab 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -51,7 +51,7 @@ Logger.prototype.removeLevel = function() { Logger.prototype.log = function() { var args = Array.prototype.slice.call(arguments) - , logLevel = levels.toLevel(args.shift()) + , logLevel = levels.toLevel(args.shift(), levels.INFO) , loggingEvent; if (this.isLevelEnabled(logLevel)) { loggingEvent = new LoggingEvent(this.category, logLevel, args, this);