From 1fa9d029a2a0c3ea2bd34873e2c31a3adcd90a11 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Thu, 19 May 2011 15:25:13 +0200 Subject: [PATCH] added possibility to define global and local log levels --- lib/log4js.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/log4js.js b/lib/log4js.js index 298bd16..46e7bab 100644 --- a/lib/log4js.js +++ b/lib/log4js.js @@ -265,14 +265,25 @@ function LoggingEvent (categoryName, level, message, exception, logger) { */ function Logger (name, level) { this.category = name || DEFAULT_CATEGORY; - this.level = Level.toLevel(level, levels.TRACE); + + if (! this.level) { + this.setLevel('TRACE'); + } } sys.inherits(Logger, events.EventEmitter); Logger.prototype.setLevel = function(level) { + this.__proto__.level = Level.toLevel(level, levels.TRACE); +}; + +Logger.prototype.setLocalLevel = function(level) { this.level = Level.toLevel(level, levels.TRACE); }; +Logger.prototype.removeLocalLevel = function() { + delete this.level; +}; + Logger.prototype.log = function(logLevel, message, exception) { var loggingEvent = new LoggingEvent(this.category, logLevel, message, exception, this); this.emit("log", loggingEvent);