From 22c156582f56ca0f762ad8f7fce78d2e02324177 Mon Sep 17 00:00:00 2001 From: jci-fox Date: Tue, 4 Mar 2014 09:08:27 -0600 Subject: [PATCH] Adding level checks on dynamic logging using levels.toLevel and this.isLevelEnabled prior to emiting the event will prevent the appenders from being notified if the log level provided is below the loggers level. --- lib/logger.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/logger.js b/lib/logger.js index 4da0daf..1c6ff50 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -49,9 +49,12 @@ Logger.prototype.removeLevel = function() { Logger.prototype.log = function() { var args = Array.prototype.slice.call(arguments) - , logLevel = args.shift() - , loggingEvent = new LoggingEvent(this.category, logLevel, args, this); - this.emit("log", loggingEvent); + , logLevel = levels.toLevel(args.shift()) + , loggingEvent; + if (this.isLevelEnabled(logLevel)) { + loggingEvent = new LoggingEvent(this.category, logLevel, args, this); + this.emit("log", loggingEvent); + } }; Logger.prototype.isLevelEnabled = function(otherLevel) {