added possibility to define global and local log levels

This commit is contained in:
Alexander Sulfrian 2011-05-19 15:25:13 +02:00
parent ffdfca7d99
commit 1fa9d029a2

View File

@ -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);